Stop foreground in DownloadService before calling stop

This commit is contained in:
ByteHamster 2020-11-14 18:08:52 +01:00
parent 4decd1d9fe
commit f5bbdf1666
1 changed files with 2 additions and 0 deletions

View File

@ -168,6 +168,7 @@ public class DownloadService extends Service {
startForeground(R.id.notification_downloading, notification);
syncExecutor.execute(() -> onDownloadQueued(intent));
} else if (numberOfDownloads.get() == 0) {
stopForeground(true);
stopSelf();
} else {
Log.d(TAG, "onStartCommand: Unknown intent");
@ -553,6 +554,7 @@ public class DownloadService extends Service {
if (numberOfDownloads.get() <= 0 && DownloadRequester.getInstance().hasNoDownloads()) {
Log.d(TAG, "Number of downloads is " + numberOfDownloads.get() + ", attempting shutdown");
stopForeground(true);
stopSelf();
if (notificationUpdater != null) {
notificationUpdater.run();