Restore android app stack from background
<p>Lets say I launch my app from the home screen, navigate through some activities, then I press the home key and do something else in the Gmail app. </p>

<p>After i'm done checking my mail,I press the home key again to leave the Gmail app and click my app's icon at the home screen again to return to it.</p>

<p>When I return to my app, I want it to return to the last activity I was at, NOT start a whole new session. I've been trying to figure this out all day.</p>

<p>My manifest for my first activity is as follows:</p>

<pre><code> &lt;activity android:name=".Main"
              android:label="@string/app_name"
              android:screenOrientation="portrait"
              android:alwaysRetainTaskState="true"&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;
</code></pre>

<p>The category attribute LAUNCHER makes my app ALWAYS start at activity Main, so I don't know how to go about restoring the last activity. People have told me to use sharedpreferences to save the last activity and load it on Launch, but I don't think it's intended to be done that way because it isn't very elegant. </p>
