Making sure that DownloadService always calls startForeground

This commit is contained in:
ByteHamster 2019-11-24 20:05:07 +01:00
parent 4bda044472
commit 5f5cf628ca
1 changed files with 6 additions and 2 deletions

View File

@ -163,11 +163,15 @@ public class DownloadService extends Service {
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null && if (intent != null && intent.getParcelableArrayListExtra(EXTRA_REQUESTS) != null) {
intent.getParcelableArrayListExtra(EXTRA_REQUESTS) != null) { Notification notification = notificationManager.updateNotifications(
requester.getNumberOfDownloads(), downloads);
startForeground(NOTIFICATION_ID, notification);
onDownloadQueued(intent); onDownloadQueued(intent);
} else if (numberOfDownloads.get() == 0) { } else if (numberOfDownloads.get() == 0) {
stopSelf(); stopSelf();
} else {
Log.d(TAG, "onStartCommand: Unknown intent");
} }
return Service.START_NOT_STICKY; return Service.START_NOT_STICKY;
} }