diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b16eaf24b..e80ad5a8a 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -147,7 +147,7 @@
-
+
diff --git a/src/org/linphone/BluetoothManager.java b/src/org/linphone/BluetoothManager.java
index 4e10e89d5..0a79fafc2 100644
--- a/src/org/linphone/BluetoothManager.java
+++ b/src/org/linphone/BluetoothManager.java
@@ -66,14 +66,26 @@ public class BluetoothManager extends BroadcastReceiver {
return instance;
}
- public BluetoothManager() {
+ private BluetoothManager() {
isBluetoothConnected = false;
- mContext = LinphoneService.instance().getApplicationContext();
- mAudioManager = ((AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE));
+ if (LinphoneService.isReady()) {
+ mContext = LinphoneService.instance().getApplicationContext();
+ mAudioManager = ((AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE));
+ } else {
+ Log.w("BluetoothManager tried to init but LinphoneService not ready yet...");
+ }
instance = this;
}
public void initBluetooth() {
+ if (mContext == null && LinphoneService.isReady()) {
+ mContext = LinphoneService.instance().getApplicationContext();
+ mAudioManager = ((AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE));
+ } else if (mContext == null) {
+ Log.w("BluetoothManager tried to init bluetooth but LinphoneService not ready yet...");
+ return;
+ }
+
IntentFilter filter = new IntentFilter();
filter.addCategory(BluetoothHeadset.VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY + "." + BluetoothAssignedNumbers.PLANTRONICS);
filter.addAction(Compatibility.getAudioManagerEventForBluetoothConnectionStateChangedEvent());