Skip to content

Commit

Permalink
Fix NullPointerException per #583
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgyoung committed Sep 14, 2017
1 parent 5f18674 commit eceaa9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
### Development

Bug Fixes:
- Fix ConcurrentModifictionExceptions starting ScanJobs. (#584, #588 David G. Young)

- Fix ConcurrentModifictionExceptions starting ScanJobs. (#584, #588, David G. Young)
- Fix NullPointerException when BluetoothLeScanner cannot be obtained.
(#583, David G. Young)
### 2.12.2 / 2017-08-31

[Full Changelog](https://github.com/AltBeacon/android-beacon-library/compare/2.12.1...2.12.2)
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/altbeacon/beacon/service/ScanHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.ScanFilter;
import android.bluetooth.le.ScanSettings;
import android.content.Context;
Expand Down Expand Up @@ -185,7 +186,10 @@ void stopAndroidOBackgroundScan() {
} else if (!bluetoothAdapter.isEnabled()) {
LogManager.w(TAG, "BluetoothAdapter is not enabled");
} else {
bluetoothAdapter.getBluetoothLeScanner().stopScan(getScanCallbackIntent());
BluetoothLeScanner scanner = bluetoothAdapter.getBluetoothLeScanner();
if (scanner != null) {
scanner.stopScan(getScanCallbackIntent());
}
}
} catch (SecurityException e) {
LogManager.e(TAG, "SecurityException stopping Android O background scanner");
Expand Down

0 comments on commit eceaa9a

Please sign in to comment.