I have 4 activities:
Menu -> screen 1
Menu items -> screen 2
Detailed View -> screen 3
Ordered item -> screen 4
In Menu activity(screen 1) I have a button onclick of that it goes to MenuItems activity(scrren 2 which is List view), on click of any item in the list view it to corresponding item detailed view in this activity(screen 3) I have a button called ordered view, onlclick of this it would go to Ordered item(screen 4), in this scrren 4 I have a button which will go to screen 2.
This is the flow
Screen 1 ->screen 2->screen 3->screen 4->screen 2
Prob: after doing the basic flow now when I click on back in screen 2 it goes to screen 4 and again clicking on back it goes to screen 3 which is resulting the user to click back button n no of times since the activity already exists in stack.
How to handle this I mean back button navigation.
I have tried using flags in intent but it's not working for me.
I have also referred this
edit I got the answer: so as few of my friends have answered here I used this Intent.FLAG_ACTIVITY_CLEAR_TOP
So
screen 1->screen 2->screen 3-> screen 4->screen 2
So in screen 4 I have to set this flag so that it will clear all the activities above that activity.