1.Activity Boot Mode
The four startup modes of activity in the Android system
- Standard (default)
- Singletop
- Singletask
- SingleInstance
The four startup modes are configured in Androidmanifest.xml for each activity in the parameter settings Android:launchmode
2. Pattern Features
Standard: In this mode, a new instance is generated each time it is started by using intent. Android:launchmode is not configured, the default is standard.
Singletop: This mode is similar to standard, except that if the current activity is at the top of the stack, when intent launches the activity, no new instances are generated and the original instance is reused. However, if the activity is not currently at the top of the stack, a new instance is regenerated. If the intent parameter flag_activity_new_task is specified, it will be restarted to another task.
Singletask: In this mode, activity will only have one instance. If an instance of the activity already exists in a task, the new one is no longer started and is reused every time, and reuse is if the activity is at the bottom of the task's stack and will be transferred to the top of the stack.
SingleInstance: The only difference between this pattern and singletask is that, in this mode, the activity will own a task independently, not be shared with other activity, each activity is reused, and there can be only one instance of the global.
3. Example Demo