Please read first the documentation: http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html http://developer.android.com/guide/practices/ui_guidelines/activity_task_design.html
There are more solutions for your problem. For example when the user presses the "Back A button" start your A activity with Intent and use the FLAG_ACTIVITY_CLEAR_TOP flag. On 5 April 2011 14:55, Serdel <[email protected]> wrote: > Maybe the title of this topic is not quite proper but it considers the > life cycle of android activities. I looked through many open source > project and saw that usually when an activity is opened form a basic > one the main screen is not closed. When the user presses the 'back' > button the new activity is closed and the main one stays on screen. > > However in my application I have a problem with that - the new > activity needs to have a button getting it back to the first one. > Moreover, the new activity can open a third one that still would have > the button that should take back to the first one. Or even a 4th one. > So it looks like that: > > A => B => C => D > > And all B,C,D need to have a button that would close the all 'chain' > and get back to A. Let's call it 'Back A button' not to confuse with > 'hardware back button'. I didn't know how to close all other > activities by a push of the mentioned ''Back A button'. If don't close > them, I'll have a flood of activities in the background. > > I achieved this by closing each activity when calling the next one. So > When I open B I close A, when I open C I close B, When I open D I > close C etc.This works however whenever you would press the 'hardware > back button' on the android device the whole application exits (there > are no running activities 'in the back'). I don't want this since the > user would expect to get back to the previous screen by pressing > hardware back button. So i.e. D=>C, C=>B, B=>A. > > I don't know if I had explained my problem in detail, I hope so. Does > any one have an advice on how to handle this situation? > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

