Possible Duplicate:
Removing an activity from the history stack
Suppose I have three activities on my stack, like this A → B → C.
I would like to terminate B and replace it with an activity D, so that the stack looks like this : A → D → C.
The intended effect is to have a “screen chooser” activity C. It opens on top of activity B, offers a number of things to choose from, and when the user clicks one, it closes, revealing the chosen screen. I can cancel the opening animation with overridePendingTransition, but that alone won’t help me reveal the activity by closing the chooser interface.
Is there any way to do that in Android ?
I have two starts of real anwsers. The first is not perfect but very easy to implement; the second one should give the expected results but is harder to implement.
One is to start activities with the FLAG_ACTIVITY_REORDER_TO_FRONT and FLAG_ACTIVITY_PREVIOUS_IS_TOP. This will give the expected behavior for any existing activity. It still does not work if the activity is not already in the back of the stack, notably on its first start.
Another possibility – which I have not implemented yet – is to create an ActivityManager very much like a TabHost and pass intents to this guy. It then takes the responsibility of loading the next activity in its onNewIntent() method. This should work and allows for separate development of separate activities.