[android-developers] TaskAffinity causes new instance being created when startActivity

2010-06-09 Thread James Wang
Hi,
I have a problem about taskAffinity of Activity.
Activities A and B with the same taskAffinity.

A starts B with FLAG_ACTIVITY_NEW_TASK and the B starts A with
FLAG_ACTIVITY_NEW_TASK again.
Dumpsys activity of system gives us task stack like below:

TOP- A
  B
  A

According to SDK's reference to FLAG_ACTIVITY_NEW_TASK, the result is
supposed to be like below:
TOP - A
   B

If we did not set taskAffinity, A will not be created again but in
different task stack from B. (A and B are in different Apps)

After a little more research, we found FLAG_ACTIVITY_REORDER_TO_FRONT
is what we want.

My question is whether SDK' reference to FLAG_ACTIVITY_NEW_TASK is
wrong?

Thanks,

James

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


Re: [android-developers] TaskAffinity causes new instance being created when startActivity

2010-06-09 Thread Dianne Hackborn
Why are you using NEW_TASK?  You shouldn't do so unless you  have a good
reason (like you are implementing a launcher).

On Wed, Jun 9, 2010 at 1:10 AM, James Wang jameswangc...@gmail.com wrote:

 Hi,
 I have a problem about taskAffinity of Activity.
 Activities A and B with the same taskAffinity.

 A starts B with FLAG_ACTIVITY_NEW_TASK and the B starts A with
 FLAG_ACTIVITY_NEW_TASK again.
 Dumpsys activity of system gives us task stack like below:

 TOP- A
  B
  A

 According to SDK's reference to FLAG_ACTIVITY_NEW_TASK, the result is
 supposed to be like below:
 TOP - A
   B

 If we did not set taskAffinity, A will not be created again but in
 different task stack from B. (A and B are in different Apps)

 After a little more research, we found FLAG_ACTIVITY_REORDER_TO_FRONT
 is what we want.

 My question is whether SDK' reference to FLAG_ACTIVITY_NEW_TASK is
 wrong?

 Thanks,

 James

 --
 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.comandroid-developers%2bunsubscr...@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