This question already has an answer here:
- Android: Clear the back stack 31 answers
I start from activity A->B->C->D->E ..when i go from D->E there should be no activity in stack but, the user can use back button from D and go to C (without refreshing Activity C, like normal back function)
You could add a
BroadcastReceiver
in all activities you want to close (A, B, C, D):... and close them by calling ...
... in activity E. Check this nice example too.
Add flags to your itent it will clear all activities in a stack
this is the right wat to clear back activities already in a stack
Hope this helps..
Add flag FLAG_ACTIVITY_CLEAR_TOP to your intent to clear your other Activities form Back stack when you are starting your E Activity like :
then start your Activity :
More Information on : Task and BackStack