Skip to content

Commit

Permalink
Merge pull request #154 from pepyakin/master
Browse files Browse the repository at this point in the history
Fix service preemption by putting it into foreground.
  • Loading branch information
cpeterso committed Oct 31, 2013
2 parents bb92c16 + 9e3f534 commit 4a35c68
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/org/mozilla/mozstumbler/ScannerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class ScannerService extends Service {
public static final String MESSAGE_TOPIC = "org.mozilla.mozstumbler.serviceMessage";

private static final String LOGTAG = ScannerService.class.getName();
private static final int NOTIFICATION_ID = 0;
private static final int NOTIFICATION_ID = 1;
private static final int WAKE_TIMEOUT = 5 * 1000;

private Scanner mScanner;
Expand Down Expand Up @@ -105,6 +105,7 @@ public void run() {

NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.cancel(NOTIFICATION_ID);
stopForeground(true);

mScanner.stopScanning();

Expand Down Expand Up @@ -216,7 +217,7 @@ public void run() {

int icon = R.drawable.ic_status_scanning;
Notification n = buildNotification(ctx, icon, title, text, contentIntent, flags);
nm.notify(NOTIFICATION_ID, n);
startForeground(NOTIFICATION_ID, n);
}
});
}
Expand Down

0 comments on commit 4a35c68

Please sign in to comment.