I have five activity in my app,
Act1->Act2->Act3->Act4->Act5,
All activity goes in single direction as I have stated above,
Now I have to call again Act2 after successful completion of my Act5’s task, so its working good and showing me the Act2 (I have Used startActivity(callIntent) in Act5 for showing me Act2 again),
After this when I click on Back button in Act2, I have Act1 (I have Used startActivity(callIntent) in Act2 for showing me Act1 again) its what I want …..
But the problem is that when I click Act1’s back button it is going to put me on Act2. But I want to exit from there, because Act1 is the first initial activity.
How Can I set focus to my hidden activity , instead of creating Intent and call startActivity.
Any idea? Please help.
After long research I got pretty much understanding of “back stack” for all the activities in an app.
Each time I moved to another activity and also for opening previous activity I have used
Intent.startActivity()withflag FLAG_ACTIVITY_NEW_TASK, So every time I have new activity added in the “back-stack”.I have tried intent flag as
FLAG_ACTIVITY_CLEAR_TOPwhile calling previous activity from “back-stack” usingIntent.startActivity()and I got the solution of calling back the previous activity and clears all stack top activity above the calling one activity. So now back button does working nice as I needed.Let see My problem of calling previous activity ,
A = activity; A1->A2->A3->A4->A5->B2, now if you click on back button you will have A1 activity , and after clicking on A1’s back button you have again B2 activity which was called after A5 and so on.After using the
FLAG_ACTIVITY_CLEAR_TOPin A5 activity and called again A2 (Not creating new activity but calling precious one) I have following situation.calling previous A2 activity, and I have following scenario.
A1->A2only.Thanks.