Reputation: 7219
Read the documentation but unclear as to the purpose of the DEAFAULT category in the manifest. Is it possible to have more than 1 intent-filter with the DEFAULT category attribute in the same manifest?
Upvotes: 2
Views: 1507
Reputation: 3704
Yes it is possible to have more than one. From the documentation here is why you would need the default category:
*Note: In order to receive implicit intents, you must include the CATEGORY_DEFAULT category in the intent filter. The methods startActivity() and startActivityForResult() treat all intents as if they declared the CATEGORY_DEFAULT category. If you do not declare this category in your intent filter, no implicit intents will resolve to your activity.* - http://developer.android.com/guide/components/intents-filters.html
Example of having more than one intent filter with default category:
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="myscheme"/>
</intent-filter>
Upvotes: 3
Reputation: 1006664
Is it possible to have more than 1 intent-filter with the DEFAULT category attribute in the same manifest?
Sure. Most activities that have an <intent-filter>
will support the DEFAULT
category, as that category is automatically added to an Intent
used with startActivity()
if there is no other category on the Intent
already.
For example, in the manifest for the AOSP Music app, you can see a variety of <activity>
elements, with and without <intent-filter>
elements. Those that have <intent-filter>
may or may not use DEFAULT
.
Upvotes: 0