Skip to content

Commit 4a35c68

Browse files
committed
Merge pull request #154 from pepyakin/master
Fix service preemption by putting it into foreground.
2 parents bb92c16 + 9e3f534 commit 4a35c68

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/org/mozilla/mozstumbler/ScannerService.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public final class ScannerService extends Service {
2525
public static final String MESSAGE_TOPIC = "org.mozilla.mozstumbler.serviceMessage";
2626

2727
private static final String LOGTAG = ScannerService.class.getName();
28-
private static final int NOTIFICATION_ID = 0;
28+
private static final int NOTIFICATION_ID = 1;
2929
private static final int WAKE_TIMEOUT = 5 * 1000;
3030

3131
private Scanner mScanner;
@@ -105,6 +105,7 @@ public void run() {
105105

106106
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
107107
nm.cancel(NOTIFICATION_ID);
108+
stopForeground(true);
108109

109110
mScanner.stopScanning();
110111

@@ -216,7 +217,7 @@ public void run() {
216217

217218
int icon = R.drawable.ic_status_scanning;
218219
Notification n = buildNotification(ctx, icon, title, text, contentIntent, flags);
219-
nm.notify(NOTIFICATION_ID, n);
220+
startForeground(NOTIFICATION_ID, n);
220221
}
221222
});
222223
}

0 commit comments

Comments
 (0)