Intent Filter是在mainfest內設定的
介紹如下
Explicit intent在使用時不管intent filter的宣告
而intent filter的使用是在mainfest內用<intent-filter>使用
<action>
在 name 屬性中,宣告接受的intent action。
必須是動作的常數字串,不能是class內的常數。
ex: <action android:name="string" />
<data>
使用一或多項屬性來宣告接受的資料類型。
ex: <data android:scheme="string"
android:host="string"
android:port="string"
android:path="string"
android:pathPattern="string"
android:pathPrefix="string"
android:mimeType="string" />
<category>
在 name 屬性中,宣告接受的intent category。
必須是動作的常數字串,不能是class內的常數。
ex: <category android:name="string" />
一個intent filter可以有多個 <action>、 <data> 或 <category>
一個元件也可以有多個intent filter
在Service時要使用explicit intent去啟動
對Activity必須在manifest內宣告所有的filter
而broadcast receivers則可以動態的用registerReceiver()註冊
和unregisterReceiver()來解除filter
*如果要限定只有自己的應用程式能啟動該元件
則需將 exported 屬性設定為 "false"。
1. 官網https://developer.android.com/guide/components/intents-filters.html#Receiving