Manipulate the back of the activity stack in Android?

You could start B with FLAG_ACTIVITY_NO_HISTORY flag. So it will not go to the stack and C will make a decision to start D or B. Does it fit what you need?

No, it doesn't for two reasons. The first one, it will prevent the user to return to it from the screen chooser with the back key. The second one, it doesn't change that it will open the new one on top of the screen chooser, which is exactly what I am trying to avoid.

– Jean Nov 12 '10 at 12:14 Look, you can start needed activity in the chooser's onDestroy(). If nothig is changed in chooser - it starts B, otherwise it starts D, and closes itself. So on back key onDestroy() will be called and you "return" to B activity.

How it looks? – ackio Nov 13 '10 at 5:11 In general it is not good idea to change the stack and it's the unexpected behavior for android user. But if you still want it this hack could help.

– ackio Nov 13 '10 at 5:23.

Another idia)) B and D are the same activity(!) which has B-mode and D-mode with defferent layouts. When it's in B-mode it starts C with StartActivityForResult(). And on returning it decides which layout to inflate.

Pretty easy, right?

This does work. But I'm working in a pretty big team, and we develop a dozen of different screens - putting them all in the same activity is very inconvenient, to say the least. That being said, I can't think of any other decent way, short of having the chooser take a screenshot and pass it to everyone else and requiring to display it first with a closing animation and... yuck.

Anyway thanks a lot, I don't think it can be done any other decent way than making it a single activity with several modes. – Jean Nov 15 '10 at 9:57.

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.

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.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions