Android. Intent. Category. LauncherWhat is the specific function? I will make a small example to help you understand
<Activity Android: Name = "apact">
<Intent-filter>
<Action Android: Name = "android. Intent. Action. Main"/>
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
</Activity>
<Activity Android: Name = "urlact">
<Intent-filter>
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
</Activity>
An application can have multiple activities, each of which is at the same level. Which activity is the first to start when a program is started? Some programs may need to be displayed in the program list, while others do not. How to define it? Android. Intent. Action. Main determines the activity Android. Intent. Category. launcher that the application first starts to determine whether the application is displayed in the program list.
Because your program may have many activities
As long as the xml configuration file contains such an intent-filter and the launcher, this activity is the first activity to run when you click the program.
<Activity Android: Name = "apact">
<Intent-filter>
<Action Android: Name = "android. Intent. Action. Main"/>
</Intent-filter>
</Activity>
<Activity Android: Name = "urlact">
<Intent-filter>
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
</Activity>
If the code looks like this, will it still be displayed in the list, that is, main and launcher are used together?
<Activity Android: Name = "apact">
<Intent-filter>
<Action Android: Name = "android. Intent. Action. Main"/>
<Category Android: Name = "android. Intent. Category. launcher"
/>
</Intent-filter>
</Activity>
<Activity Android: Name = "urlact">
<Intent-filter>
<Action Android: Name = "android. Intent. Action. Main"
/>
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
</Activity>
If so, two icons will appear in the list.
Used to set the activity to be enabled by default when the simulator is started.
Why Android. Intent. Category. Default?
It means that each implicit intent sent by startactivity () method has at least one category, that is"android.intent.category.DEFAULT
", So any activity that wants to receive an implicit intent should include"android.intent.category.DEFAULT
"
Category. Otherwise, intent matching fails.
The following information can also be obtained from the above discussion:
1. An intent can have multiple category items, but at least one of them is the default category.
2. The activity receives the intent only when all intent category matches.