Android – Killing android application on pause

androidandroid-1.5-cupcake

I have an application which I would like to be fully disabled/closed when it is paused (IE. When the user presses the Home, End (call) and Back button I would like the application to be closed, instead of being saved in the history stack).

How do I do this….?

Thanks.

Best Solution

Implement onPause() in your activity and call finish() on your activity. Bear in mind, though, that this will occur on every pause, including dialogs, incoming calls, users activating a Notification. You might want to consider doing finish() in onStop(), which would at least solve the dialog problem.

Also, bear in mind that users will may get confused when using your app, thinking it has crashed since it is gone when they try to get back to it.