On Wed, Apr 27, 2011 at 10:55 PM, Eric <[email protected]> wrote:

> 6. If the user hits the HOME button while in Task B (NOT the main
> application Task), and then they re-enter the App via the launcher
> (for Activity A1, Task A), how can I cause the App to enter back where
> I left off in Task B?  The LAUNCHER doesn't know about Task B, but
> there must be a way?  Do I need to override onCreate() in Activity A1,
> look up the last active task/activity name I stored in
> SharedPreferences, and then startActivity on that Activity in
> onCreate(), then call finish() on A1 (which the LAUNCHER just
> launched)?
>

You can't.  They are separate tasks.  That is the point of having separate
tasks -- they operate independently, and switching to one does not impact
the other.


> 7. If I want two separate Tasks in my app, do I actually need to
> define the Activities to have explicit taskAffinity in the manifest
> (i.e. Activity A1,A2,A3 with affinity "A", and B1, B2, B3 with
> affinity "B")?  Or can I allow Activity A1, A2, A3 to inherit the main/
> default application Task affinity, and then just start Task B from my
> menu using FLAG_ACTIVITY_NEW_TASK, whereby Android will assign a new
> globally unique Task affinity to Activity B1, B2, B3 in Task B?
>

Yes you need to give them independent task affinities, or else you can have
cases where they get mixed together.  For example, when you are launching an
activity with NEW_TASK and this causes any existing task to come to the
foreground, which task should be brought to the foreground is determined to
some degree by the task affinities.


> I hope my questions makes sense, and I'm not thinking about this
> wrong.  If I am, I would appreciate it if someone would describe the
> proper way to have multiple Tasks within an Application, and the
> proper way to jump around to each Task.  Or, possibly suggest another
> Paradigm that will achieve the same goal without the use of multiple
> Tasks?
>

The proper way to have multiple tasks is to implement something like the
launcher, where the user is switching between independent tasks that are
shown as independent entities on the recent tasks list etc.  If that is not
the behavior you want, you don't want to use multiple tasks.

-- 
Dianne Hackborn
Android framework engineer
[email protected]

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 [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

Reply via email to