Steps:
- User starts app from Android Market application
-
User clicks “Start child”
stack: ActivityMain > ActivityChild
-
User presses home button and returns to the app through “launch icon”
-
Android opens “last task” + create next ActivityMain
stack: ActivityMain > ActivityChild > ActivityMain
I expect that click on “lauch icon” will just return to previous stack [without actually creating new activity].
I expect stack:
ActivityMain > ActivityChild
How to achive it???
On the other hand, when user in the above 1st step starts app dicertly from “launch icon” then the problem does’n exist.
Manifest:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="ActivityMain"
android:name=".ActivityMain" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="ActivityChild"
android:name=".ActivityChild" >
</activity>
</application>
Thanks for help!
Solution:
Introduce “launcher activity” which is responsibe for:
– either starting new task,
– or restoring previous task.
Launcher is started as “singleInstance”.
For example, assume we have activities:
Now at some moment user executed sequence:
then HOME
and then return to app but by launcher icon “ActLauncher”.
This brings user to full previous back stack:
I applied the solution in this app
There:
– ActLauncher = “invisible”
– ActChild1 = main screen
– ActChild2 = game screen
Best wishes!