-1

A part of my code: (Problem Explanation follows)

@Override
protected void onStop() {
    super.onStop();
    if(mediaPlayer != null){
        mediaPlayer.release();
        mediaPlayer = null;
    }
}

My main idea of using this was to stop playing the audio when the home button was pressed, but this doesn't seem to be happening as audio isn't stopping. Thanks in advance.. :)

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
ColonP
  • 7
  • 3

1 Answers1

0

You are hooking into the Activities onStop() method to stop the audio however when you press the home button, an Activities state is being saved, and therefore the activity calls its onPause() method instead of onStop().

If you want to stop audio when the home button is pressed, I suggest moving your call to the media player that's stopping it, into the Activities onPause() method.

Nate Schreiner
  • 759
  • 2
  • 7
  • 15