1. In Androidmanifest.xml, you can set multiple intent-filter for each activity,service;
After system startup and program installation, Android collects the intent-filter configured in Androidmanifest.xml.
Each intent-filter filters the intent from the action category data three amount.
- Setting rules for Intent-filter and Intent
1. Each Intent-filter object (here is intent-filter not a child node of Intent-filter in Androidmanifest.xml, the Activity node can have no Intent-filter child node ) can be configured 0-n action, 1-n category, 0-n data. Scheme, host, port, path, mimetype can be set on the data node on the Intentfilter
2. Each intent can be set up 0-1 action, 0-n category, 0-1 data. You can use the Uri to set data on Intent, using string settings mimetype
3. When installing the app, the system does not set a default category if the Intent-filter node is not configured with a category.
If StartActivity (intent), when the activity is implicitly started, the system automatically matches the intent once more "Android.intent.category.DEFAULT", So if you want to be able to start the activity implicitly,
The activity must be configured with "Android.intent.category.DEFAULT" in Androidmanifest.xml, otherwise it will not be matched in any way.
- Matching rules for Intent-filter and Intent
Match Step 1,action 2, Data 3,category
Action and category matching rules:
The action in the intent must be set in the Intent-filter
Each category in the intent must be set in the Intent-filter.
Data matching rules
Data Format:<scheme>://
In the previous match, the data in intent only needs to match the part set in the Intent-filter.
For example, set <data android:scheme= "test" android:host= "www.google.com" in Intent-filter/>
So
Uri.parse ("test://www.google.com:80"),
Uri data = Uri.parse ("test://www.google.com:88"),
Uri data = Uri.parse ("test://www.google.com")
These three can all be matched.
If MimeType is set, the MimeType is also set in intent.
Intent matching Rules