Andro Selva Andro Selva - 1 year ago 87
Android Question

mediaPlayer won't stop even if I finish the activity

I am in a situation where I have an ActivityGroup and inside of which I have an Activity in which I have used MediaPlayer to play an audio file. But when I navigate out of that Activity I am trying to stop the MediaPlayer, but unfortunately I was not able to do it. So I tried finishing my activity when I navigate out of it. I am able to finish the activity but still MediaPlayer doesn't stop at all.

How should I solve this.

Answer Source

MediaPlayer won't stop when you finish your activity, you need to explicitly call mMediaPlayer.stop() in your activity's onPause().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download