Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android clear back stack between activities

I have 4 activities: Activity A -> activity B -> Activity C -> activity D and I what I want to achieve is to go back from D to A and clear B and C. Is this possible?? How??

Thanks a lot.

like image 629
Kabuki Avatar asked Mar 20 '17 12:03

Kabuki


1 Answers

If the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

Intent intent = new Intent(this, ActivityA.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

Read more here.

like image 81
Charlie Avatar answered Oct 02 '22 12:10

Charlie