1, to understand this problem, first need to figure out what is implicit (hidden) Intent what is explicit (clear) intent.
Explicit Intent explicitly specifies the acitivity to start, such as the following Java code:
[Java] view Plaincopyprint?
-
intent intent= new , b. class
Implicit intent does not explicitly specify which activity to start, but instead sets some intent filter to allow the system to filter the appropriate acitivity to start.
2, intent exactly to which activity, need to do three matches, one is action, one is category, one is data.
Theoretically, if intent does not specify category, then whatever the contents of the intent filter should be matched. However, if it is implicit intent,android default to add a category_default, so if intent If the category is not Android.intent.category.DEFAULT in filter, the match test will fail. So, if your activity supports receiving implicit intent, be sure to include Android.intent.category.DEFAULT in intent filter.
Exceptions are:
[Java] view Plaincopyprint?
<intent-filter>
<action android:name="Android.intent.action.MAIN" />
<category android:name="Android.intent.category.LAUNCHER" />
</intent-filter>
There is no need to join the Android.intent.category.DEFAULT, of course, there is no problem. This is the first startup activity that the app launches by default (with so many activity for each app, one must be the first one to start)
If you define an activity to be initiated implicitly, you must add Android.intent.category.DEFAULT to the ANDROIDMANIFAST.XM, otherwise it will not work.
In addition, there are many uses for category
For example, make a desktop, press the home button to start your own application
[HTML] view Plaincopyprint?
-
< activity
-
android:name ". Mainactivity "
-
android:label = "@string/ App_name "
< Intent-filter >
<Action Android:name="Android.intent.action.MAIN" />
<category Android:name="Android.intent.category.LAUNCHER"/>
<category Android:name="Android.intent.category.HOME" />
-
</ intent-filter >,
</ Activity >
How to configure the three matching data in intent, and simply say
That is, when you do not directly specify the activity to jump to, provide intent with some relevant parameters, let it automatically and androidmanifest.xml in the existing activity to match
Intentfilter three main parameters in XML: Action,categary,data.
We can specify this three parameters through the intent constructor or the method provided by intent:
[Java] view Plaincopyprint?
Intent.setaction (action);
Intent.setdata (data);
Intent.addcategory (category);
Uses and uses of Android Android.intent.category.DEFAULT