Not understanding Activity stack?
<p>I'm having trouble with my activities when they go in the background. I have two activities, A and B. Only A can launch B (manifest copied below). This is what I do:</p>

<ol>
<li>Launch the app from the app drawer (activity A)</li>
<li>There's a button on A to launch B, B now is displayed.</li>
<li>Hit the Home key, my app is now in the background.</li>
<li>Go to the app drawer again, hit my app icon.</li>
<li>Instead of resuming at ActivityB, Activity A is launched again. Why?</li>
<li>If I hit the Back key now, I get shown the old ActivityB. What?</li>
</ol>

<p>This is very confusing. It's like Android knows my app is running, and puts a new instance of A on top of the old B instance running. I'd just expect that the application gets paused in-place, and whenever the user hits the app icon again, it just picks up where it left off (in this case, just show B again!) Below is the manifest, and the activity classes for this test are completely empty (except A which has a button to launch B).</p>

<pre><code>&lt;activity android:name=".ActivityA"
              android:label="@string/app_name"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;
            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;

    &lt;activity android:name=".ActivityB"
          android:label="@string/app_name"&gt;
        &lt;intent-filter&gt;
        &lt;!-- 
            &lt;action android:name="android.intent.action.VIEW" /&gt;
             --&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;
            &lt;category android:name="android.intent.category.DEFAULT" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
</code></pre>
