Skip to content

Commit

Permalink
Attempt to prevent crash on stopping foreground service by moving up …
Browse files Browse the repository at this point in the history
…stopForeground call. Always stop intent based scans on job stop.
  • Loading branch information
davidgyoung committed Nov 8, 2018
1 parent e0d5b44 commit d7b0884
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ public IBinder onBind(Intent intent) {
@Override
public boolean onUnbind(Intent intent) {
LogManager.i(TAG, "unbinding so destroying self");
this.stopForeground(true);
this.stopSelf();
return false;
}
Expand All @@ -325,7 +326,6 @@ public void onDestroy() {
if (mBeaconNotificationProcessor != null) {
mBeaconNotificationProcessor.unregister();
}
stopForeground(true);
bluetoothCrashResolver.stop();
LogManager.i(TAG, "onDestroy called. stopping scanning");
handler.removeCallbacksAndMessages(null);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/altbeacon/beacon/service/ScanJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public boolean onStopJob(JobParameters params) {

private void stopScanning() {
mInitialized = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mScanHelper.stopAndroidOBackgroundScan();
}
mScanHelper.getCycledScanner().stop();
mScanHelper.getCycledScanner().destroy();
LogManager.d(TAG, "Scanning stopped");
Expand Down

0 comments on commit d7b0884

Please sign in to comment.