Need more info regarding intent-filter tag specified in manifest. I am aware that we can specify data in two forms:
<intent-filter>
<data android:host="com.myHost" android:scheme="content"/>
</intent-filter>
AND :
<intent-filter>
<data android:scheme="content"/>
<data android:host="com.myHost"/>
</intent-filter>
But I wish to know can several combinations exist, like
<intent-filter>
<data android:host="com.myHost" android:scheme="content"/>
<data android:scheme="content"/>
<data android:host="com.myHost1"/>
</intent-filter>
OR:
<intent-filter>
<data android:host="com.myHost" android:scheme="content"/>
<data android:scheme="content"/>
<data android:host="com.myHost1"/>
<data android:scheme="content"/>
<data android:host="com.myHost2"/>
</intent-filter>
In the last case, I wish to know firstly if this can exist & how is it decided that which host to be used for which scheme, as the data tags containing scheme & host can occur in any order.
Please help.
I am aware that we can specify data in two forms
Do not use content
for a scheme, unless you truly mean that you are creating an activity in support of a ContentProvider
.
But I wish to know can several combinations exist
If your filter has just one attribute for <data>
, you definitely can have different values, such as this from the Contacts app:
<activity
android:name=".activities.ShowOrCreateActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="com.android.contacts.action.SHOW_OR_CREATE_CONTACT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="mailto" />
<data android:scheme="tel" />
</intent-filter>
</activity>
Also, one component can have several <intent-filter>
elements, each of which is logically OR'd with the others (any Intent
matching any filter is a match for the component). So for more complex scenarios, where you have 2+ attributes per <data>
element, I would be inclined to put those in separate <intent-filter>
elements.
how is it decided that which host to be used for which scheme
Any match is considered good. You would examine the Intent
yourself to learn more about what it contains.