Search code examples
androidmedia-playerback-button

Why media player is still playing when I press back button


I know that we can use onPause() event to stop the MediaPlayer using reset() method. But I want to know why media player is still playing when I press back button?


Solution

  • I believe your media player is being run by a Service. So when you press back key, it only destroys the Activity, not the Service. So you need to stop the service too in your activity's onStop method