Activity Four startup modes and activity Four modes
Activity has four startup modes:
1. standard, default startup mode. If Activity is activated, a new instance is created and put into the task stack. In this way, multiple instances of one Activity may exist in the task stack at the same time.
2. singleTop: when the Activity is activated, if the Activity is on the top of the stack, no new instances will be created. if the Activity is not on the top of the stack, a new instance will be created.
3. singleTask: If an Activity instance exists in the stack, the instances of other activities above the stack are removed so that the Activity instance is at the top of the stack. If no instance exists in the stack, create a new instance.
4. singleInstance: one instance where multiple applications share an Activity. whether the Activity is activated or not, the instance is reused.
You can set the Startup Mode for the Activity in AndroidManifest. xml by setting the android: launchMode attribute.
Some applications need to jump back and forth in two forms, such as A --> B, B --> ,......, in this case, you need to set the start mode of A and B to singleTask. Otherwise, when you press the return key, A and B will jump back and forth.