I have my app, and I want it to exit once I switch to something else. example: when I'm in my app and press the home button, the app should exit, and disappear from the background running apps window. how would I do this? maybe in onDestroy?
Asked
Active
Viewed 301 times
0
-
This happens for the mobile banking Apps. Isnt it? – A user Jun 02 '17 at 14:31
2 Answers
0
Looks like a duplicate of How to quit android application programmatically. You can try use Activity.onPause
method for your purpose, but check some tricky workflows like switching phone off etc.

rupashka
- 399
- 3
- 8
-
still a problem there: when i start the application, it instantly calls onPause – Ian Rehwinkel Jun 02 '17 at 15:00
0
Finish the App onPause
then the app will not be run in the background.
@Override
public void onPause() {
super.onPause();
isForeground = false;
finish();
}

Ramana V V K
- 1,245
- 15
- 24