Fix NullPointerException in IntentScanStrategyCoordinator
@@ -209,7 +209,8 @@ class IntentScanStrategyCoordinator(val context: Context) {
val scanStartTime = System.currentTimeMillis()
if (adapter != null) {
- val scanner: BluetoothLeScanner = adapter.getBluetoothLeScanner()
+ val scanner: BluetoothLeScanner? = adapter.getBluetoothLeScanner()
+ if (scanner != null) {
val callback: ScanCallback = object : ScanCallback() {
override fun onScanResult(callbackType: Int, result: ScanResult) {
super.onScanResult(callbackType, result)
@@ -229,7 +230,7 @@ class IntentScanStrategyCoordinator(val context: Context) {
LogManager.d(TAG, "Sending onScanFailed event")
}
}
- if (scanner != null) {
+
try {
scanner.startScan(callback)
while (beaconDetected == false) {
