steve steve - 4 months ago 13x
Android Question

Finish all activities at a time

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?


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

Intent intent = new Intent(getApplicationContext(), FirstActivity.class);
intent.putExtra("EXIT", true);

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

if (getIntent().getBooleanExtra("EXIT", false)) {

and you are done....