Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finish Activity in BackStack - Android

In my app I have activities A, B, C, D and E. First activity is A then opening B and then C and D. Now my back stack is A-B-C-D. Now when I move to E from D I want to finish all the activity in back stack and now E should be the first activity in stack.

In my case

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 

or

android:launchMode="singleTask"

didn't work, because I am not reopening an activity which is already opened. I have to close all the activity in backstack while opening a new activity.

Please help me to do this.

like image 266
Sniper Avatar asked Nov 10 '22 15:11

Sniper


1 Answers

Set following flags:

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
Intent.FLAG_ACTIVITY_CLEAR_TASK);

FLAG_ACTIVITY_CLEAR_TASK is available from api 11 though.

like image 80
vipul mittal Avatar answered Nov 14 '22 22:11

vipul mittal