1. To solve this problem, you must first understand what is implicit (hidden) intent and what is explicit (explicit) intent.
Explicit intent explicitly specifies the acitivity to be startedFor example, the following Java code:
Intent intent = new intent (this, B. Class)
Implicit intent does not explicitly specify the activity to startInstead, you can set some intent filters to enable the system to filter the appropriate acitivity.
2. Which activity does intent send? Three matches are required. One is action, the other is category, and the other is data.
Theoretically, if the intent does not specify the category, the content of the intent filter should match everything. However, if it is implicit intent, Android will add a category_default by default. In this way, if the category Android. Intent. Category. Default is not included in the intent filter, the matching test will fail. Therefore, if your activity supports receiving implicit intent, you must add Android. Intent. Category. default to the intent filter.
The exception is that android. Intent. Category. Main and Android. Intent. Category. launcher do not need to be added to the filter of Android. Intent. Category. Default. Of course, it is no problem to add the filter.
If the defined activity accepts implicit intent, the android. Intent. Category. Default category must be added to intent filer.
II,
Android. Intent. Category. LauncherWhat is the specific function? There is no difference between adding or not in XML. Who can explain it!
<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, but some 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.
Now you only have one activity, so it does not matter if you do not add it.
Used to set the activity to be enabled by default when the simulator is started.
Iii. explanations from another article:
When I wrote androidmanifest. XML, I never figured out when to filter activityandroid. Intent. Category. default.
Android treats all implicit intents passedstartActivity()
As if they contained at least one category :"android.intent.category.DEFAULT
"(
CATEGORY_DEFAULT
Constant). Therefore, activities that are willing to receive implicit intents must include"android.intent.category.DEFAULT
"In their intent Filters
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.
Categories provided by Android
Value |
Description |
Alternative |
A replaceable execution method for default intent data actions |
Selected_alternative |
Alternative is similar, but the alternative execution method is parsed instead of specified. |
Browsable |
Declare that the activity can be started by the browser |
Default |
Provides default actions for the data defined in the intent Filter |
Home |
The first activity displayed after the device is started |
Launcher |
The application is first displayed when it is started. |