Android‎ > ‎

Going Back Multiple Activity/Finishing Multiple Activity

posted Mar 14, 2013, 3:16 AM by Akash Khaitan   [ updated Mar 14, 2013, 3:21 AM ]
Often I used to create a new activity whenever it was required to finish multiple activity. This resulted in repetition of many activity.

Just a simple addition of line took me back to the desired activity and removed all the activities above it. Thus no repetitions of activity now

Current we are on Activity D
A -> B -> C -> D

To go to B

Intent intent = new Intent(getApplicationContext(), B.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);                                //This line startActivity(intent);

Removes activities
D, C, B

Again launches activity B

Thus we have

A-> B