I have an application with 4 or 5 activities! Let’s say A, B, C, D and E.
It is more or less possible to jump from every activity to every other activity!
Lets say a user goes A -> B -> E -> D.
Now he wants to open B (again). I now want my application to recognise, that there already is one active B somewhere in the activity stack and reactivate it (or at least finish the old B and create a new one).
I dont want to finish all activities when creating new ones, because it is likely that the user often uses the backbutton.
possible solutions would be: create a activity stack yourself and process it in bundles or to use some static structures.
But there has to be a much simpler/nicer way, is there??
Thanks for your help!
You can use
singleInstancevalue orsingleTaskvalue in launch mode tag in your manifest.android:launchMode=["multiple" | "singleTop" |"singleTask" | "singleInstance"]According to android developers fundamentals
The
singleTaskandsingleInstancemodes also differ from each other only in one respect:A
singleTaskactivity allows other activities to be part of its task. It’s always at the root of its task, but other activities (necessarilystandardandsingleTopactivities) can be launched into that task.A
singleInstanceactivity, on the other hand, permits no other activities to be part of its task. It’s the only activity in the task. If it starts another activity, that activity is assigned to a different task — as ifFLAG_ACTIVITY_NEW_TASKwas in the intent.