I have an application with multiple pages i.e., multiple activities and some of them remain open.
Is there a way to close all activities at once?
I have an application with multiple pages i.e., multiple activities and some of them remain open.
Is there a way to close all activities at once?
The best solution i have found, which is compatible with devices having API level <11
This solution requires Android support library
Following two flags worked for me. They will clear all the previous activities and start a new one
Hope this helps.
Whenever you wish to exit all open activities, you should press a button which loads the first Activity that runs when your application starts then clear all the other activities, then have the last remaining activity finish. to do so apply the following code in ur project
The above code finishes all the activities except for FirstActivity. Then we need to finish the FirstActivity's Enter the below code in Firstactivity's oncreate
and you are done....
For API 16+, use
For lower, use
If rooted:
I was struggling with the same problem. Opening the about page and calling
finish();
from there wasn't closing the app instead was going to previous activity and I wanted to close the app from the about page itself.This is the code which worked for me:
Hope this helps.