Handling Bluetooth off during scanning
This commit is contained in:
parent
54c1b227a4
commit
d68e771a78
|
@ -73,6 +73,8 @@ public class BootloaderScannerJB implements BootloaderScanner, BluetoothAdapter.
|
|||
}, "Scanner timer").start();
|
||||
|
||||
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (adapter == null || adapter.getState() != BluetoothAdapter.STATE_ON)
|
||||
return null;
|
||||
adapter.startLeScan(this);
|
||||
|
||||
try {
|
||||
|
|
|
@ -78,7 +78,11 @@ public class BootloaderScannerLollipop extends ScanCallback implements Bootloade
|
|||
}, "Scanner timer").start();
|
||||
|
||||
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (adapter == null || adapter.getState() != BluetoothAdapter.STATE_ON)
|
||||
return null;
|
||||
final BluetoothLeScanner scanner = adapter.getBluetoothLeScanner();
|
||||
if (scanner == null)
|
||||
return null;
|
||||
/*
|
||||
* Scanning with filters does not work on Nexus 9 (Android 5.1). No devices are found and scanner terminates on timeout.
|
||||
* We will match the device address in the callback method instead. It's not like it should be, but at least it works.
|
||||
|
|
Loading…
Reference in New Issue