Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Clear all previous activities~?

Activity Flow in my app.

WelcomeActivity -> SignInActivity -> SignUpActivity -> TabsActivity(this is main) -> ...


Activity Stack


I want to close all previous activities (Welcome, SignIn, SignUp) when start TabsActivity.

I try several method...

  1. TabsActivity. clear task on launch=true ? but not work (maybe)

  2. TabsActivity. launch mode = singleTask ? but not work

But I do not want to "save 3 activities and call each activity.finish()"

Depending on the situation, "available 2 or 4 activities not 3", or "I do not know What activities is in activity stack".


I want to clear all previous activities, regadless of any situation.

Help me :)

Sorry my poor english... Thanks.

like image 910
ChangUZ Avatar asked Jan 14 '23 07:01

ChangUZ


1 Answers

If I understand correctly, you might want to try starting your TabsActivity with the following code:

    Intent intent = new Intent(getApplicationContext(), TabsActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);

The flag Intent.FLAG_ACTIVITY_CLEAR_TOP clears the history.

like image 69
Zerga Avatar answered Jan 28 '23 08:01

Zerga