How to finish() an Activity when Home button pressed

Viewed 16931

For a complicated reason I need to be able to finish() my activities when the user presses the HOME button.

The story here is that I have a homescreen widget that launches a different part of my application that has a completely transparent activity (so the homescreen keeps showing even though my activity is running). If the previous activities were terminated via Home button, they are brought to the foreground and obscure the home screen.

Or as alternative, can I have the new activity somehow force finish() the previous activity?

5 Answers

I had the problem with closing the sound on home button is pressed. I did this code below. Hope it wil help you. Override onpause() method.

 @Override
 public void onPause(){
      System.exit(0);
      super.onPause(); 
 }
Related