On May 16, 11:33 pm, Dianne Hackborn <[email protected]> wrote:
> 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.
I'm doing some more testing, and things are starting to make more
sense with respect to switching tasks. My problem was that my IDE is
launching my application in a slightly different way than the LAUNCHER
icon does, and I think that's why I'm seeing duplicate Activities on
my Task stack, instead of the task resuming.
So, what you're saying is, if I want to have multiple tasks within my
app, and I want to switch back to the MAIN app task programmatically
from my app, I need to supply the Intent I use with ACTION_MAIN and
CATEGORY_LAUNCHER flags so that the 'switch' back is to the same task
that the app launcher started?
What if I want to make sure the same Task is resume in 3 different
cases:
- app LAUNCHER
- long-press HOME Task switcher
- programmatically within my app
It seems I can match my programmatic Task switcher with ACTION_MAIN
and CATEGORY_LAUNCHER to satisfy the LAUNCHER case, but what about the
case where the app is resumed via long-press HOME Task swticher? My
experience is that you get a completely different Intent there, along
the lines of:
05-17 12:30:43.740: INFO/ActivityManager(101): Starting: Intent
{ flg=0x10100000 cmp=com.mycompany.android.myapp/.MyMainActivity }
from pid 101
05-17 12:30:43.800: INFO/activities.MyMainActivity(2264): onRestart
(10) -- Intent { flg=0x800000
cmp=com.mycompany.android.myap/.MyMainActivity }
I'm worried in this case the Intent doesn't match with the LAUNCHER,
and you'd end up with a separate Task? In fact, this would affect all
apps that use both MAIN LAUNCHER icon, and long-press HOME Task
switcher. Exactly which item(s) on the Intent are checked when
determining which Task should be resumed (flags, action, category,
component, etc)?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en