How to kill stack activity

Please tell me any one, how to kill previous stacked activity.My requirement is like that let I move from activity A---->B----->C------>D----->E Then activity stack will be E-D-C-B-A Now I am at E if my all work is done then I move to activity B using

startActivity(intent); 

this.finish();

this code will be kill only E activity but I want to kill C D activity also. how can I do that. thanks.

Answers


One solution is to call Activity [B] with flag FLAG_ACTIVITY_CLEAR_TOP

Intent b = new Intent(this,B.class);
b.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(b);
this.finish();

This will kill C D E


Need Your Help

Linq Distinct not being very Distinct

c# wpf linq

Is this linq statement correct for getting unique values of 'Name' from my newSpecs collection?

linq query returning any where a class field that exists in a list

linq lambda contains any

i want to filter a list by a field within the list where the field exists within a set of values. i am trying to get filter the list where a Guid field exists in a list of guids