Four modes:
The activity mode is actually about "task" and "instantiation ".
| |
Instantiation |
Task |
| Standard |
Multiple examples |
The preceding and following activities are in the same task. |
| SingleTop |
Single Instance/multiple instances |
The preceding and following activities are in the same task. |
| SingleTask |
Singleton |
It is not in the same job as the previous one, but in the same job as the subsequent one (start a new job stack with this root) |
| SingleInstance |
Singleton |
Not in the same job as others (not in the same job stack as others) |
1. standard: standard mode: the same activity that is instantiated multiple times can be on the same task stack (for example, ABABAAB). Purpose: Most
2. singleTop: Single-top mode: instantiated once at the top of the stack (for example, ABABAB ). purpose?
3. singleTask: single-task mode: starts a new job stack and uses this as the root. (For example, CA and BACA [B is a single task]). purpose: to use a single task (or to prevent page refresh and optimize memory), you also need a single task (for example, startActivtyForResult is used ),
4. singleInstance: A Job stack, an isolated island. (AC, B, AC [B is a Singleton]). purpose: for example, if you want to enable an activity for ten activty stacks. the standard is too performance-consuming. single top, not used, single task (for example, ABCD, B is an activity, AC wants to enable acitivity of B), if A first enable B, B then enable D, C has enabled B and wants to enable E. see figure. I think we should use the singleton at this time.
PS: The Singleton mode and the singletaskmode are both one instance. It is usually used when the construction cost is large but the switching cost is small. Is the construction cost high? It is to do a lot of work during construction!