Manipulate the back of the Android action stack

Possible duplicate:
Removing activity from the history stack

Suppose I have three actions on my stack, for example, A β†’ B β†’ C.
I would like to complete B and replace it with activity D, so the stack looks like this: A β†’ D β†’ C.
The intended effect is to activate the "on-screen selection" C. It opens on top of activity B, offers a lot of things to choose from, and when the user clicks one, it closes, showing the selected screen. I can cancel opening the animation using overridePendingTransition, but this alone will not help me open the activity by closing the selection interface.

Is there any way to do this in Android?

+4
source share
3 answers

I have two beginnings of real anders. The first is not perfect, but very easy to implement; the second should give the expected results, but more difficult to implement.

One of them is to start actions with 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, especially on the first start.

Another opportunity that I have not yet implemented is to create an ActivityManager very similar to TabHost and pass the intent on to this guy. He then takes responsibility for loading the next activity into his onNewIntent () method. This should work and allows separate development of individual activities.

+1
source

You can run B with the flag FLAG_ACTIVITY_NO_HISTORY. Therefore, it will not go onto the stack, and C will decide to start D or B. Does it match what you need?

+2
source

Another idia)) B and D are one and the same activity (!), Which has a B-mode and a D-mode with different layouts. When it is in mode B, it starts C with StartActivityForResult (). And on his return, he decides which layout to inflate. Pretty easy, right?

+1
source

All Articles