Fix reappearing notification
This commit is contained in:
parent
8fe6db84e8
commit
fa07f612cf
2 changed files with 9 additions and 29 deletions
|
|
@ -169,7 +169,6 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
};
|
};
|
||||||
private ContentObserver mediaStoreObserver;
|
private ContentObserver mediaStoreObserver;
|
||||||
private boolean notHandledMetaChangedForCurrentTrack;
|
private boolean notHandledMetaChangedForCurrentTrack;
|
||||||
private boolean isServiceBound;
|
|
||||||
|
|
||||||
private Handler uiThreadHandler;
|
private Handler uiThreadHandler;
|
||||||
|
|
||||||
|
|
@ -337,12 +336,13 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
break;
|
break;
|
||||||
case ACTION_STOP:
|
case ACTION_STOP:
|
||||||
case ACTION_QUIT:
|
case ACTION_QUIT:
|
||||||
return quit();
|
quit();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return START_STICKY;
|
return START_NOT_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -364,24 +364,9 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
isServiceBound = true;
|
|
||||||
return musicBind;
|
return musicBind;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRebind(Intent intent) {
|
|
||||||
isServiceBound = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onUnbind(Intent intent) {
|
|
||||||
isServiceBound = false;
|
|
||||||
if (!isPlaying()) {
|
|
||||||
stopSelf();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class QueueSaveHandler extends Handler {
|
private static final class QueueSaveHandler extends Handler {
|
||||||
@NonNull
|
@NonNull
|
||||||
private final WeakReference<MusicService> mService;
|
private final WeakReference<MusicService> mService;
|
||||||
|
|
@ -460,18 +445,13 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
queuesRestored = true;
|
queuesRestored = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int quit() {
|
private void quit() {
|
||||||
pause();
|
pause();
|
||||||
playingNotification.stop();
|
playingNotification.stop();
|
||||||
|
|
||||||
if (isServiceBound) {
|
|
||||||
return START_STICKY;
|
|
||||||
} else {
|
|
||||||
closeAudioEffectSession();
|
closeAudioEffectSession();
|
||||||
getAudioManager().abandonAudioFocus(audioFocusListener);
|
getAudioManager().abandonAudioFocus(audioFocusListener);
|
||||||
stopSelf();
|
stopSelf();
|
||||||
return START_NOT_STICKY;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void releaseResources() {
|
private void releaseResources() {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import static android.content.Context.NOTIFICATION_SERVICE;
|
||||||
public abstract class PlayingNotification {
|
public abstract class PlayingNotification {
|
||||||
|
|
||||||
private static final int NOTIFICATION_ID = 1;
|
private static final int NOTIFICATION_ID = 1;
|
||||||
protected static final String NOTIFICATION_CHANNEL_ID = "playing_notification";
|
static final String NOTIFICATION_CHANNEL_ID = "playing_notification";
|
||||||
|
|
||||||
private static final int NOTIFY_MODE_FOREGROUND = 1;
|
private static final int NOTIFY_MODE_FOREGROUND = 1;
|
||||||
private static final int NOTIFY_MODE_BACKGROUND = 0;
|
private static final int NOTIFY_MODE_BACKGROUND = 0;
|
||||||
|
|
@ -33,7 +33,7 @@ public abstract class PlayingNotification {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public void update();
|
public abstract void update();
|
||||||
|
|
||||||
public synchronized void stop() {
|
public synchronized void stop() {
|
||||||
stopped = true;
|
stopped = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue