I’ve got two activity tasks running in an Android app and I’d like a way to pop the second task completely and return to the top of the first task. The problem is, the top task in the first stack could be an number of different Activities.
Say I’ve got Task 1 with a stack of activities
Task 1 -> A1 -> A2 -> A3
I then start Task 2:
Task 2 -> B1 -> B2 -> B3
When I get to B3, I’d like to pop the entire Task 2 stack and get back to A3. I know I could start a new intent with A3 as the specified intent activity class however my Task 1 could look like this:
Task 1 -> A1 -> A2
Is there any easy way without tracking the last activity of Task 1 to simply pop everything off of Task 2, simply returning me to the top of the Task 1 stack regardless of the activity’s class?
I am not sure if this is what you want, but when you create the intent to call the new activity you can set a flag which cleans the stack.
You can use eclipse auto complete to see the other available flags, if this is not exactly what you need.
And here is a list of all flags and what they do.
http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP