I'm trying to figure out how to implement an interesting concept.
Suppose there's a bar at the bottom of my application with 3 buttons. We'll call them A, B, C. I want you to think of these as 3 areas of the app, each with their own Activity stack.
Suppose I press B, I am first taken to the main B screen. Suppose this screen has some functionality within it to take me to another screen, say the details of a particular item on a list.
Now, while on the details screen, I press button C at the bottom and I'm taken to the main C screen.
If I press B (or press the back button), I want the user to be taken to the last screen in the B Activity stack, which is the details screen, and not the main B screen.
Is this possible? If I understand things correctly, I should have 3 tasks, 1 for A, 1 for B, and 1 for C, yes? What else would I have to do?
Of course that's possible and simple to implement. But you must read this to understand how to implement that.
You have 3 root activities: A_main, B_main, C_main. Each activity should start a new task. To do that u need:
In your manifest declare different affinities for them:
activity android:name=".A_main" android:taskAffinity=".A"
activity android:name=".B_main" android:taskAffinity=".B"/>
To start (switch) task start new intent using flags (you can use ApplicationContext):
private static final int ROOT_INTENT_FLAG =
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
To provide an ui opportunity to switch between tasks you can use e.g. android menu. If you want to clear task - just add flag Intent.FLAG_ACTIVITY_CLEAR_TOP
And...you need some LauncherActivity which will be launched when your application starts. This activity should restore last visited task and finish itself. To restore - just use intent with flags from above (item 2).