I would like to know how I can achieve this, if it is killing all the Activities, because I am doing a kind of Password Manager.
I would like to know how I can achieve this, if it is killing all the Activities, because I am doing a kind of Password Manager.
Do you intend to use the methods of onPause () and onResume () in the flow of your application? There is no exact method to want to do what you like but without any doubt you have to send the kill of your app from the method of onPause () as far as I understand.
If you are looking for a little more info, I found this page I hope it works, otherwise I recommend you check the flow of the apps for android, for when they go from different states and want to run things between these states, onPause, onResume, etc.
I hope and help you a little. Solution to detect when an Android app goes to the background and come back to the foreground
Each Activity has its own life cycle, if you want to detect when it
find in the background about the onPause()
method:
@Override
protected void onPause() {
super.onPause();
//La app esta en segundo plano (background).
}
How to know if my app is in the background?
As to how to end it you can use the previous method to detect the application is in the background, now let's see how to end the application:
Make an app end when it is in the background?
For this you can use the API method from finishAffinity ()
finishAffinity () : Finish this activity as well as all the activities immediately below it in the current task that have the same affinity.
Therefore your code would be:
@Override
protected void onPause() {
finishAffinity()
super.onPause();
}
Completely, with regard to finishing the application you can see the options suggested by @WebServeis in your answer: