beautify notification updates

This commit is contained in:
Adrian Ulrich 2015-10-01 22:28:50 +02:00
parent 103d78f075
commit 7eaa37d97c

View File

@ -566,7 +566,7 @@ public final class PlaybackService extends Service
mForceNotificationVisible = false; mForceNotificationVisible = false;
pause(); pause();
stopForeground(true); // sometimes required to clear notification stopForeground(true); // sometimes required to clear notification
mNotificationManager.cancel(NOTIFICATION_ID); updateNotification();
} }
MediaButtonReceiver.registerMediaButton(this); MediaButtonReceiver.registerMediaButton(this);
@ -978,13 +978,14 @@ public final class PlaybackService extends Service
if (mMediaPlayerInitialized) if (mMediaPlayerInitialized)
mMediaPlayer.pause(); mMediaPlayer.pause();
if (mNotificationMode == ALWAYS || mForceNotificationVisible) { // We are switching into background mode. The notification will be removed
stopForeground(false); // unless we forcefully show it (or the user selected to always show it)
if (mCurrentSong != null) // In both cases we will update the notification to reflect the
mNotificationManager.notify(NOTIFICATION_ID, createNotification(mCurrentSong, mState)); // actual playback state (or to hit cancel() as this is required to
} else { // get rid of it if it was created via notify())
stopForeground(true); boolean removeNotification = (mForceNotificationVisible == false && mNotificationMode != ALWAYS);
} stopForeground(removeNotification);
updateNotification();
// Delay entering deep sleep. This allows the headset // Delay entering deep sleep. This allows the headset
// button to continue to function for a short period after // button to continue to function for a short period after