Killing an Android app in pause mode

I have an application that I would like to completely disable / close when it is paused (IE. When the user clicks the "Home", "End" and "Back" buttons, I would like the application to close and not be saved in the history stack )

How to do it...?

Thanks.

+9
source share
3 answers

Add onPause() to your activity and call finish() in your activity. Keep in mind that this will happen every pause, including dialogs, incoming calls, users who activate Notification . You might want to consider finish() in onStop() , which will at least solve the dialog problem.

Also, keep in mind that users may get confused when using your application, thinking that it crashed since it disappeared when they try to return to it.

+24
source

you can easily do this by setting the true attribute "noHistory" to your activity element in the manifest

http://developer.android.com/guide/topics/manifest/activity-element.html#nohist

+12
source

You know how you have the OnCreate () method in your activity that performs actions at startup. You need to add something like:

 @Override protected void onPause(){ finish(); super.onPause(); } 

in your activity to add actions prior to its launch

in this case

 finish(); 

a team is what you want to execute before your activity pauses.

+2
source

Source: https://habr.com/ru/post/887475/


All Articles