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