diff --git a/ble/src/main/java/no/nordicsemi/android/ble/BleManager.java b/ble/src/main/java/no/nordicsemi/android/ble/BleManager.java index 195f9b95..092fc621 100644 --- a/ble/src/main/java/no/nordicsemi/android/ble/BleManager.java +++ b/ble/src/main/java/no/nordicsemi/android/ble/BleManager.java @@ -257,11 +257,17 @@ public void onReceive(final Context context, final Intent intent) { // The connection is killed by the system, no need to disconnect gently. mUserDisconnected = true; + // Allow new requests when Bluetooth is enabled again. close() doesn't do it. + // See: https://github.com/NordicSemiconductor/Android-BLE-Library/issues/25 + // and: https://github.com/NordicSemiconductor/Android-BLE-Library/issues/41 + mGattCallback.mOperationInProgress = false; + // This will call close() mGattCallback.notifyDeviceDisconnected(mBluetoothDevice); + } else { + // Calling close() will prevent the STATE_OFF event from being logged + // (this receiver will be unregistered). But it doesn't matter. + close(); } - // Calling close() will prevent the STATE_OFF event from being logged - // (this receiver will be unregistered). But it doesn't matter. - close(); break; } }