Skip to content

Commit 788e2df

Browse files
Merge pull request #1368 from shancock884/fix-double-invoke-v11
[backport] Ensure enable bluetooth callback is set to null on exception (#1367)
2 parents 1c2c8b4 + b86be37 commit 788e2df

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

android/src/main/java/it/innove/BleManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,17 @@ public void enableBluetooth(Callback callback) {
188188
return;
189189
}
190190
if (!getBluetoothAdapter().isEnabled()) {
191-
enableBluetoothCallback = callback;
192191
Intent intentEnable = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
193192
if (getCurrentActivity() == null)
194193
callback.invoke("Current activity not available");
195194
else
196195
{
196+
enableBluetoothCallback = callback;
197197
try{
198198
getCurrentActivity().startActivityForResult(intentEnable, ENABLE_REQUEST);
199199
}catch(Exception e){
200-
callback.invoke("Current activity not available");
200+
enableBluetoothCallback = null;
201+
callback.invoke("Error starting enable bluetooth activity");
201202
}
202203

203204
}

0 commit comments

Comments
 (0)