Do not hide notification on audio focus loss
This commit is contained in:
parent
f35286f1dc
commit
f0acfa4263
@ -326,7 +326,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.d(TAG, "Service is about to be destroyed");
|
||||
stateManager.stopForeground(true);
|
||||
stateManager.stopForeground(!UserPreferences.isPersistNotify());
|
||||
isRunning = false;
|
||||
currentMediaType = MediaType.UNKNOWN;
|
||||
|
||||
@ -733,7 +733,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
|
||||
@Override
|
||||
public void shouldStop() {
|
||||
stateManager.stopService();
|
||||
setupNotification(getPlayable()); // Stops foreground if not playing
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,8 @@
|
||||
package de.danoeh.antennapod.core.service.playback;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.Service;
|
||||
import android.os.Build;
|
||||
|
||||
class PlaybackServiceStateManager {
|
||||
private final PlaybackService playbackService;
|
||||
@ -19,12 +21,19 @@ class PlaybackServiceStateManager {
|
||||
|
||||
void stopService() {
|
||||
stopForeground(true);
|
||||
isInForeground = false;
|
||||
playbackService.stopSelf();
|
||||
}
|
||||
|
||||
void stopForeground(boolean removeNotification) {
|
||||
playbackService.stopForeground(removeNotification);
|
||||
if (isInForeground) {
|
||||
if (Build.VERSION.SDK_INT < 24) {
|
||||
playbackService.stopForeground(removeNotification);
|
||||
} else if (removeNotification) {
|
||||
playbackService.stopForeground(Service.STOP_FOREGROUND_REMOVE);
|
||||
} else {
|
||||
playbackService.stopForeground(Service.STOP_FOREGROUND_DETACH);
|
||||
}
|
||||
}
|
||||
isInForeground = false;
|
||||
hasReceivedValidStartCommand = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user