Stop the application by calling lifecycle callbacks

How can I stop the entire application in simple terms? (all actions, services, flows, etc. are just everything). Lifecycle callbacks (especially onStop()and onDestroy()) should be called .

Google offers the following possible solution:

  • kill the process: but this will not cause lifecycle callbacks
  • and finish (); but this is only for one action:

But is it possible to access this method from the outside, for example:

//Getting all activityies, how?
//For each gotten activity
AcitvityName.finish();
or via or via getParent().finish(); ?

This did not help me: The best way to exit the Android application

Fd

+5
source share
3 answers
 @Override 
public void onPause() {        

        if(isFinishing()){
//code to finish() all activitys threads etc.....
}            

    super.onPause();
} 

onPause() isFinishing(), , , onDestroy(), - , ,

+2

Android . .

, , :

Clear the activity stack in the onDestroy method (or, if you want, onBackPressed, onHomePressed). It should call Destroy methods in all uninstall actions, so you can release any extended resources in the onDestroy method that has references to it.

Therefore, when a user exits your application, he removes his actions and frees all resources.

+1
source

All Articles