0

This is an image from android documentation:

enter image description here

Activity Y has 'singleTask' launch mode but it is not root activity in the task, that is Activity X. How did it happen?

Upd.:

From the documentation:

"singleTask"

The system creates a new task and instantiates the activity at the root of the new task. However, if an instance of the activity already exists in a separate task, the system routes the intent to the existing instance through a call to its onNewIntent() method, rather than creating a new instance. Only one instance of the activity can exist at a time. Note: Although the activity starts in a new task, the Back button still returns the user to the previous activity.

Community
  • 1
  • 1
TpoM6oH
  • 8,385
  • 3
  • 40
  • 72

2 Answers2

0

Single task only means that this activity can only be created once cf to this website: http://inthecheesefactory.com/blog/understand-android-activity-launchmode/en

It doesn't matter if the activity is root or not.

singleTask:

This mode is quite different from standard and singleTop. An Activity with singleTask launchMode is allowed to have only one instance in the system (a.k.a. Singleton). If there is an existed Activity instance in the system, the whole Task hold the instance would be moved to top while Intent would be delivered through onNewIntent() method. Otherwise, new Activity would be created and placed in the proper Task.

Distwo
  • 11,569
  • 8
  • 42
  • 65
  • Hm, it does not agree with the official documentation... I've just posted an update to the question. – TpoM6oH Oct 14 '15 at 00:58
  • Though on second look it seems the same, the only way to start an activity is to create a new task where it will be in the root. – TpoM6oH Oct 14 '15 at 01:00
0

I think the answer is that this activity was launched with an intent with FLAG_ACTIVITY_SINGLE_TOP flag, because intents have higher priority than xml tags.

TpoM6oH
  • 8,385
  • 3
  • 40
  • 72