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 boolean notHandledMetaChangedForCurrentTrack;
|
||||
private boolean isServiceBound;
|
||||
|
||||
private Handler uiThreadHandler;
|
||||
|
||||
|
|
@ -337,12 +336,13 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
break;
|
||||
case ACTION_STOP:
|
||||
case ACTION_QUIT:
|
||||
return quit();
|
||||
quit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return START_STICKY;
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -364,24 +364,9 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
isServiceBound = true;
|
||||
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 {
|
||||
@NonNull
|
||||
private final WeakReference<MusicService> mService;
|
||||
|
|
@ -460,18 +445,13 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
queuesRestored = true;
|
||||
}
|
||||
|
||||
private int quit() {
|
||||
private void quit() {
|
||||
pause();
|
||||
playingNotification.stop();
|
||||
|
||||
if (isServiceBound) {
|
||||
return START_STICKY;
|
||||
} else {
|
||||
closeAudioEffectSession();
|
||||
getAudioManager().abandonAudioFocus(audioFocusListener);
|
||||
stopSelf();
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
closeAudioEffectSession();
|
||||
getAudioManager().abandonAudioFocus(audioFocusListener);
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
private void releaseResources() {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import static android.content.Context.NOTIFICATION_SERVICE;
|
|||
public abstract class PlayingNotification {
|
||||
|
||||
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_BACKGROUND = 0;
|
||||
|
|
@ -33,7 +33,7 @@ public abstract class PlayingNotification {
|
|||
}
|
||||
}
|
||||
|
||||
abstract public void update();
|
||||
public abstract void update();
|
||||
|
||||
public synchronized void stop() {
|
||||
stopped = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue