Reputation: 6128
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.
Upvotes: 3
Views: 2833
Reputation: 5061
you have to use finish() after every intent so this activity will be close.
The you can intent function from 4 activity to 2 activity . Also use finish after it.
http://nanostuffs.com/Blog/?p=607
u have to check the link in this link uses a child activity for a main activity for tab .
Upvotes: 0
Reputation: 6108
Intent intent= new Intent(this, screen 1.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Upvotes: 8
Reputation: 4751
What you want to do is set screen 2 to have launchMode singleTop in the manifest. This ensures that there is only one of those activities in your stack at one time. You also want to set the clear top flag in your intent.
Intent a = new Intent(this,A.class);
a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(a);
Upvotes: 1
Reputation: 5061
you have to use finish() after every intent so this activity will be close.
The you can intent function from 4 activity to 2 activity . Also use finish after it.
Upvotes: 1