Skip to content Skip to sidebar Skip to footer

My Android App Crashes After Pressing The Home Button

i have an activity which has a scrollview and MediaPlayer, while the music is playing and i press home, it closed normal, but when i press the home button without the music or anyt

Solution 1:

I suppose, the "Home button" is your phone home button. You probably have an error in your onPause or onDestroy method. Send us your error log.

Solution 2:

Check your onDestroy() and onPause() methods. Probabily you are not closing the MediaPlayer.

Solution 3:

public void onPause() { 
    super.onPause(); 
    mp.pause(); 
}

The only possible cause of NullPointerException here is mp being null. Check if you assign null to it anywhere in your code or if you initialize it.

Solution 4:

I've also met the same problem .. The simple solution is just implement onPause() method and put your stop code there ....

Post a Comment for "My Android App Crashes After Pressing The Home Button"