As I said in another thread, if you want to switch apps you need to use the
exact same Intent that you used originally to start the task.  If you don't,
then you are launching a new activity instance for that new Intent.

If you want to match what a home screen launches, then you need ACTION_MAIN,
CATEGORY_LAUNCHER.

On Mon, May 16, 2011 at 8:12 PM, Eric <e...@alum.mit.edu> wrote:

>  I created a test app which has two tasks to duplicate the
> functionality of my more complex app.  When I hit the HOME button, and
> then resume the app (task), instead of bringing you back to the place
> in the task stack where I left off (MyActivityA2), Android adds
> another copy of the root task to the top (MyActivityA1).  This is
> despite the fact that the documentation says its supposed to bring you
> back to the activity in the task where you left off.
>
> 1. When I hit HOME --> app icon from LAUNCHER, I lose task state.
> 2. When I hit HOME --> Long-press HOME, and switch task using task
> switcher, I don't lose state.
>
> Is this the expected behavior?  I would like the app to resume at the
> last place regardless of whether the user re-launches from the
> LAUNCHER, or re-launches by using the task switcher when at HOME.
> Otherwise, the Task stack looks like the following, with duplicate
> Activities in the stack (instead of just MyActivityA1, MyActivityA2).
>
> Task Stack:
>
>  * TaskRecord{4098ea78 #109 A com.example}
>    clearOnBackground=false numActivities=4 rootWasReset=false
>    affinity=com.example
>    intent={flg=0x10000000 cmp=com.example/.MyActivityA1}
>    realActivity=com.example/.MyActivityA1
>    lastActiveTime=116677973 (inactive for 9s)
>    * Hist #23: HistoryRecord{409879a8 com.example/.MyActivityA2}
>        packageName=com.example processName=com.example
>        launchedFromUid=10081 app=ProcessRecord{406f0e18
> 9349:com.example/10081}
>        Intent { cmp=com.example/.MyActivityA2 }
>        frontOfTask=false task=TaskRecord{4098ea78 #109 A com.example}
>        taskAffinity=com.example
>        realActivity=com.example/.MyActivityA2
>        base=/data/app/com.example-2.apk/data/app/com.example-2.apk
> data=/data/data/com.example
>        labelRes=0x7f040000 icon=0x7f020000 theme=0x0
>         stateNotNeeded=false componentSpecified=true
> isHomeActivity=false
>        configuration={ scale=1.0 imsi=0/0 loc=en_US touch=3
> keys=1/1/2 nav=3/1 orien=2 layout=34 uiMode=17 seq=16}
>         launchFailed=false haveState=false icicle=null
>        state=RESUMED stopped=false delayedResume=false
> finishing=false
>         keysPaused=false inHistory=true launchMode=0
>         fullscreen=true visible=true frozenBeforeDestroy=false
> thumbnailNeeded=false idle=true
>        waitingVisible=false nowVisible=true
>     * Hist #22: HistoryRecord{409bf6c8 com.example/.MyActivityA1}
>        packageName=com.example processName=com.example
>        launchedFromUid=10026 app=ProcessRecord{406f0e18
> 9349:com.example/10081}
>         Intent { act=android.intent.action.MAIN
> cat=[android.intent.category.LAUNCHER] flg=0x10600000
> cmp=com.example/.MyActivityA1 }
>        frontOfTask=false task=TaskRecord{4098ea78 #109 A com.example}
>        taskAffinity=com.example
>        realActivity=com.example/.MyActivityA1
>        base=/data/app/com.example-2.apk/data/app/com.example-2.apk
> data=/data/data/com.example
>        labelRes=0x7f040000 icon=0x7f020000 theme=0x0
>         stateNotNeeded=false componentSpecified=true
> isHomeActivity=false
>        configuration={ scale=1.0 imsi=0/0 loc=en_US touch=3
> keys=1/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=15}
>        launchFailed=false haveState=true
> icicle=Bundle[mParcelledData.dataSize=204]
>         state=STOPPED stopped=true delayedResume=false finishing=false
>        keysPaused=false inHistory=true launchMode=0
>        fullscreen=true visible=false frozenBeforeDestroy=false
> thumbnailNeeded=false idle=true
>     * Hist #21: HistoryRecord{40956df8 com.example/.MyActivityA2}
>        packageName=com.example processName=com.example
>        launchedFromUid=10081 app=ProcessRecord{406f0e18
> 9349:com.example/10081}
>        Intent { cmp=com.example/.MyActivityA2 }
>        frontOfTask=false task=TaskRecord{4098ea78 #109 A com.example}
>        taskAffinity=com.example
>        realActivity=com.example/.MyActivityA2
>        base=/data/app/com.example-2.apk/data/app/com.example-2.apk
> data=/data/data/com.example
>        labelRes=0x7f040000 icon=0x7f020000 theme=0x0
>         stateNotNeeded=false componentSpecified=true
> isHomeActivity=false
>        configuration={ scale=1.0 imsi=0/0 loc=en_US touch=3
> keys=1/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=15}
>        launchFailed=false haveState=true
> icicle=Bundle[mParcelledData.dataSize=204]
>         state=STOPPED stopped=true delayedResume=false finishing=false
>        keysPaused=false inHistory=true launchMode=0
>        fullscreen=true visible=false frozenBeforeDestroy=false
> thumbnailNeeded=false idle=true
>     * Hist #20: HistoryRecord{40569808 com.example/.MyActivityA1}
>        packageName=com.example processName=com.example
>        launchedFromUid=2000 app=ProcessRecord{406f0e18
> 9349:com.example/10081}
>        Intent { flg=0x10000000 cmp=com.example/.MyActivityA1 }
>        frontOfTask=true task=TaskRecord{4098ea78 #109 A com.example}
>        taskAffinity=com.example
>        realActivity=com.example/.MyActivityA1
>        base=/data/app/com.example-2.apk/data/app/com.example-2.apk
> data=/data/data/com.example
>        labelRes=0x7f040000 icon=0x7f020000 theme=0x0
>         stateNotNeeded=false componentSpecified=true
> isHomeActivity=false
>        configuration={ scale=1.0 imsi=0/0 loc=en_US touch=3
> keys=1/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=15}
>        launchFailed=false haveState=true
> icicle=Bundle[mParcelledData.dataSize=204]
>         state=STOPPED stopped=true delayedResume=false finishing=false
>        keysPaused=false inHistory=true launchMode=0
>        fullscreen=true visible=false frozenBeforeDestroy=false
> thumbnailNeeded=false idle=true
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to