Fix PlaybackService.onDestroy

Pausing in onDestroy was broadcasting an update which would
cause receivers to restart the service and/or crash.
This commit is contained in:
Christopher Eby 2011-09-02 00:41:17 -05:00
parent 7c00dc4496
commit 283a53e4db

View File

@ -283,18 +283,17 @@ public final class PlaybackService extends Service implements Handler.Callback,
{ {
ContextApplication.setService(null); ContextApplication.setService(null);
super.onDestroy(); mLooper.quit();
// clear the notification
stopForegroundCompat(true);
if (mMediaPlayer != null) { if (mMediaPlayer != null) {
mTimeline.saveState(this, mMediaPlayer.getCurrentPosition()); mTimeline.saveState(this, mMediaPlayer.getCurrentPosition());
unsetFlag(FLAG_PLAYING);
mMediaPlayer.release(); mMediaPlayer.release();
mMediaPlayer = null; mMediaPlayer = null;
} }
mLooper.quit();
MediaButtonHandler.unregisterMediaButton(); MediaButtonHandler.unregisterMediaButton();
try { try {
@ -305,6 +304,8 @@ public final class PlaybackService extends Service implements Handler.Callback,
if (mWakeLock != null && mWakeLock.isHeld()) if (mWakeLock != null && mWakeLock.isHeld())
mWakeLock.release(); mWakeLock.release();
super.onDestroy();
} }
public void startForegroundCompat(int id, Notification notification) public void startForegroundCompat(int id, Notification notification)