mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-05 13:27:09 +01:00
Use ServiceCompat.stopForeground
This commit is contained in:
parent
f8779fbba2
commit
6c17cda0c9
@ -17,6 +17,7 @@ import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.core.app.ServiceCompat;
|
||||
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.sync.SyncService;
|
||||
@ -645,7 +646,7 @@ public class DownloadService extends Service {
|
||||
}
|
||||
handler.post(() -> {
|
||||
cancelNotificationUpdater();
|
||||
stopForeground(true);
|
||||
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE);
|
||||
stopSelf();
|
||||
});
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package de.danoeh.antennapod.core.service.playback;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.Service;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.core.app.ServiceCompat;
|
||||
|
||||
class PlaybackServiceStateManager {
|
||||
private final PlaybackService playbackService;
|
||||
@ -27,12 +27,10 @@ class PlaybackServiceStateManager {
|
||||
|
||||
void stopForeground(boolean removeNotification) {
|
||||
if (isInForeground) {
|
||||
if (Build.VERSION.SDK_INT < 24) {
|
||||
playbackService.stopForeground(removeNotification);
|
||||
} else if (removeNotification) {
|
||||
playbackService.stopForeground(Service.STOP_FOREGROUND_REMOVE);
|
||||
if (removeNotification) {
|
||||
ServiceCompat.stopForeground(playbackService, ServiceCompat.STOP_FOREGROUND_REMOVE);
|
||||
} else {
|
||||
playbackService.stopForeground(Service.STOP_FOREGROUND_DETACH);
|
||||
ServiceCompat.stopForeground(playbackService, ServiceCompat.STOP_FOREGROUND_DETACH);
|
||||
}
|
||||
}
|
||||
isInForeground = false;
|
||||
|
Loading…
Reference in New Issue
Block a user