Android: keep task's activity stack after restart from HOME

alex2k8 picture alex2k8 · Jan 14, 2010 · Viewed 9.4k times · Source

My application has two activities, that I start in this order:

HOME > A > B

Now I press HOME and launch "A" again. I would like to see activity "B" on a top of "A", but instead I get "A" - so the activity stack is cleared.

Manifest:

<activity android:name=".activity.A" android:label="A" android:alwaysRetainTaskState="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<activity android:name=".activity.B" android:label="B">
    <intent-filter>
    </intent-filter>
</activity>

What should I do?

Answer

alex2k8 picture alex2k8 · Jan 14, 2010

I figured out what is wrong...

The config is right, but I started application for debugging from Eclipse, this was the issue.

Case # 1.

Debug > A > B > HOME > A
Get: A (stack is cleared)

Case # 2.

Debug > A > BACK > A > B > HOME > A
Get: B (stack preserved)

Case # 3.

A > B > HOME > A
Get: B (stack preserved)