Problem description
Four ways to test Launchmode recently
The default mode top Singletask is already known
Except this instance mode.
My question is,
We only make 2 activity assumptions A and B, where A is instance's B is the standard mode
The starting process is a->b, B, a
This process why B is only an instance, B is the standard mode, should be recreated every time the new instance ah?
Who can help me to answer this question, it is better to do a few more examples of testing, more complex, let me fully understand the instance model
---------------------------
For:
1. Repeat the description of your question:
There are two Activity,activitya and Activtiyb,activitya in the application starting mode "SingleInstance", Activityb startup mode is "standard", boot order is activitya- >ACTIVITYB->ACTIVITYA->ACTIVITYB, Q Why is there only one instance of Activityb in the application?
Answer: ACTIVITYB for "standard" start mode, according to the starting sequence described in the topic, the new instance of Activityb will have two,
(1) A new instance of ACTIVITYB will be in the same task as the component that sent intent to start it
(2) A new instance of ACTIVITYB will run within this task
(3) Activitya is the "singleinstance" boot mode, it only produces an instance, and this instance is the root element in the task, and there is no new element in the task. and two new Activityb instances and instances of this activitya will not be in the same task
(4) These two new instances of the ACTIVITYB will be in the same TASK unless Flag_activity_new_task is included in the intent that initiates activityb. Then the new instances of these two activityb will each be run in a new task.
2. You mentioned in the question, "It is better to do a few more examples of testing, more complex, can let me fully understand the instance model", I would like to explain the theoretical analysis of a few examples, then if there is time, then design a few examples of demo to help you understand:
There are four startup modes for activity in the Android platform,
"Standard" (default)
"Singletop"
"Singletask"
"SingleInstance"
(1) "Standard" mode: The activity of this mode can create multiple instances, and each task can have more than one instance, and the one instance running within which task depends on the component that sends intent to it runs within that task;
(2) "Singletop" mode: The activity of this mode if at the top of the task stack, do not generate a new instance of the activity, directly using the instance of the top of the stack, otherwise, generate an instance of the activity;
For example, now the task stack element is a-b-c-d (d at the top of the stack), this time to send a start intent D, if D is "singletop" mode, then the new instance of D will not be produced, the stack state is still a-b-c-d; If the sender sends a intent to B, Whether B's launch mode is "standard" or "Singletop", a new instance of B is generated, and the stack state becomes a-b-c-d-b;
(3) "Singletask" mode: Only one task will have, if there is already other task and contains the instance, then call the instance of that task directly, if there is no instance of the activity in any task, create a new task, mount the instance, As the root element of a task, but the instance does not monopolize the task;
(4) "SingleInstance" mode: The activity instance will monopolize the task, other activity cannot exist in that task, if it initiates a new activity, regardless of the new activity instance's launch mode, The new activity will be run in another task.
3. Finally, attach a link to facilitate better understanding
http://blog.csdn.net/feng88724/article/details/6412638
Android Launchmode singleinstance Issues