0

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?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Ian Rehwinkel
  • 2,486
  • 5
  • 22
  • 56

2 Answers2

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
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