How to close the application when several actions are active

I opened 3 events. Now the user wants to exit the application. for this I have to finish all activities. This is not recommended, but my application wants to provide the user with such an exit point. How to close the application when several active actions

thanks

+3
source share
2 answers

All actions of any application use the same process identifier in android. this means that only one action remains in the first place, and this activity has the same process that was created by another activity. therefore, killing a process identifier is similar to terminating () for an activity. If you activated activity B from activity A. when activity B is activated, then your control passes to the onResume () method of activity A. you can use this behavior.

let you create a button that you click to exit the application. to achieve this goal. set a static boolean when clicking this method. and end the activity.

MyConstant.isApplicationTerminated = true; finish(); 

Now in every class that extends Activity override onResume() as follows

  @Override protected void onResume() { // TODO Auto-generated method stub if(MyConstant.isApplicationTerminated){ finish(); } super.onResume(); } 

This way you can exit the application

Thanks Deepak

+3
source

when the user wants to exit the start of another activity and add finish(); after super.onCreate(); and when you start the action for the flag of the set intent as

 FLAG_ACTIVITY_CLEAR_TOP 
0
source

All Articles