Skip to content

Commit 25821db

Browse files
committed
Add null check to scanner
1 parent ff23154 commit 25821db

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/android/BluetoothLePlugin.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2781,7 +2781,11 @@ public void onReceive(Context context, Intent intent) {
27812781
connections = new HashMap<Object, HashMap<Object, Object>>();
27822782
if (scanCallbackContext != null) {
27832783
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
2784-
bluetoothAdapter.getBluetoothLeScanner().stopScan(scanCallback);
2784+
BluetoothLeScanner scanner = bluetoothAdapter.getBluetoothLeScanner();
2785+
// Unsure why some devices return null
2786+
if (scanner != null) {
2787+
scanner.stopScan(scanCallback);
2788+
}
27852789
}
27862790
}
27872791
scanCallbackContext = null;

0 commit comments

Comments
 (0)