Close two activities

Asked

Viewed 268 times

0

I have two activities that are called in the following sequence: The first one is inserted a text and once clicked on a button, it leads to a second Activity. This second Activity, when clicking on the next button, is then taken to a third Activity, the first two must be finished and the third continue on the screen.

Note: I cannot finish the first by calling the second.

Is that possible?

Thank you.

1 answer

5


Do it this way, when you move to the next Activity:

Intent intent = new Intent(Activity2.this, Activity3.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);

By putting this Flag, you clear the stack of Acitivitys that are accumulating.

  • I didn’t know I had this option! I always called a Finish to Activity that calls the other. Very interesting the suggestion.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.