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() {
This way you can exit the application
Thanks Deepak
source share