release media session before shutting down media player

avoids potential unwanted callbacks
This commit is contained in:
domingos86 2016-04-08 21:16:45 -04:00
parent 280321a321
commit 378c47f8eb
1 changed files with 3 additions and 3 deletions

View File

@ -283,6 +283,9 @@ public class PlaybackService extends Service implements SharedPreferences.OnShar
PreferenceManager.getDefaultSharedPreferences(this)
.unregisterOnSharedPreferenceChangeListener(this);
if (mediaSession != null) {
mediaSession.release();
}
unregisterReceiver(headsetDisconnected);
unregisterReceiver(shutdownReceiver);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
@ -294,9 +297,6 @@ public class PlaybackService extends Service implements SharedPreferences.OnShar
unregisterReceiver(pauseResumeCurrentEpisodeReceiver);
mediaPlayer.shutdown();
taskManager.shutdown();
if (mediaSession != null) {
mediaSession.release();
}
}
@Override