Activity stacks are primarily used to manage the switching of activity. When using intent to jump to a target activity, it needs to be loaded according to the load mode of the target activity.
The activity has the following four kinds of Launchmode:
1.standard: By default, a new instance is created each time you use intent to jump to the target activity. The downside is that every time you enter, you create a new instance and execute the OnCreate method.
2.singleTop: If the target activity to jump is exactly at the top of the task (indicating that it is not currently in the target task, for example, I am on the home page, and then want to use intent to jump to the Innoxyz app's homepage, Then join the INNOXYZ home right at the top of the INNOXYZ task, just jump in instead of creating an instance, then jump directly past without creating a new. (example, currently in home screen, received a push of the home page, and the task stack in the task in the activity stack of the top is exactly the first page, then click the push directly into the instance without creating a new instance)
3.singleTask: this instance will be generated in a new task, which will be used for each invocation, and will not produce a new instance.
4.singleInstance: Is the only activity on its stack, which is reused every time.
Launchmode plays an important role in the process of multiple activity jumps, it can decide whether to generate new activity instances, whether to reuse existing activity instances, and whether to share a task with other activity instances. Here is a brief introduction to the concept of a task, which is an object with a stack structure, a task that can manage multiple activity, launch an application, and create a corresponding task.
We can configure <activity> the Android:launchmode attribute in Androidmanifest.xml for one of the above four kinds.
android:exported
-
In activity, this attribute is used to indicate whether the current activity can be started by another application component: True allows it to be started, and false does not allow it to be started.
-
Android:exported is one of the four components of Android Activity,service,provider,receiver a property in all four components.
-
Overall its main role is to support other applications to invoke the current component.
Four types of Launchmode activity in Android development