We know that it is necessary to use intent to jump between Android activity.
Intent is also divided into explicit intent and implicit intent,
The explicit intent is very simple, for example I want to jump to secondactivity in the firstactivity, just need to declare directly on the line:
New Intent (firstactivity. this, secondactivity. class);
Instead of explicitly specifying which activity to open when using implicit intent to jump between activity,
Instead, by specifying 3 parameters: Action,category,data,
Then let the system look for acativity that match these three parameters, and if there are multiple qualifying activity, the user will be asked to select one of them to open.
For example, I select a photo in the mobile album, click the "Send" button:
Then you can let me choose is to send to QQ friends, friends or send to a friend circle. This is actually an example of an implicit intent startup activity.
and deciding what intent an activity can respond to, you need to configure <intent-filter> under the <activity> tab of Androidmanifest.xml, You can specify action,category and data that the current activity can respond to, for example, I set the following code under Secondactivity:
<activity
Android:name=". Secondactivity "Android:label= "@string/title_activity_second"Android:theme= "@style/apptheme.noactionbar" > <Intent-filter> <ActionAndroid:name= "Android.intent.action.MYACTION" /> <categoryAndroid:name= "Android.intent.category.DEFAULT" /> <categoryAndroid:name= "Android.intent.category.MYCATEGORY" /> </Intent-filter>
</Activity>
Again in mainactivity by implicit intent:
Intent intent=New Intent ("Android.intent.action.MYACTION"); startactivity (Intent);
Then it started the secondactivity.
Here, it seems that we only specify the activity to open in the intent only need to respond to an action of "Android.intent.action.MYACTION" on the line, but in fact, the system when using implicit intent, will automatically help us add " Android.intent.category.default ", so--actually all the activity that needs to be initiated by the implicit intent is added <category android:name=" Android.intent.category.DEFAULT "/> This section of the statement, otherwise it will not start and prompt for errors that do not match the intent:
If the activity that you want to start implicitly is the one that the program starts with,
That is to declare the <category android:name= "Android.intent.category.LAUNCHER"/>
You don't have to write <category android:name= "Android.intent.category.DEFAULT"/> 's statement,
(Here Launcher, you open the program, the first activity that started.) In addition, launcher must be used with the action main, otherwise it will not start, i.e.:
< Intent-filter > < android:name= "Android.intent.action.MAIN"/> < android:name= "Android.intent.category.LAUNCHER"/></ Intent-filter >
The use of Android details Android.intent.category.DEFAULT