1

Gracefully close an app in Android When HOME or BACK is pressed

view story
linux-howto

http://stackoverflow.com – I have an android app which plays a sound, but when I press HOME/BACK I want the sound to stop and close the app and when the user goes back to the app, I want to start the activity again and not resume. My onPause() code: @Override protected void onPause() { super.onPause(); if (pS.isPlaying()) { pS.pause(); //stop the sound finish(); } else finish(); } When the sound is playing and I hit HOME or BACK my app FC and I am posting the Log below: 04-02 13:06:40.563: E/AndroidRuntime(925): FATAL EXCEPTION: main 04-02 13:06:40.563: E/AndroidRuntime(925): (HowTos)