標籤:
過濾分為四大類驗證
<action>
<category>
<data>
<ssp>
0.四大組件可以申明多個intent-fliter標籤。
1. Action驗證是必選項,如果沒有Action的話,驗證是失敗的。Action驗證是或者的關係,即是滿足一個就通過驗證。
eg:
<intent -infliter >
<actionandroid:name="Action1"/>
<actionandroid:name="Action2"/>
<actionandroid:name="Action3"/>
</intent -infliter ><
action = "Action1"
通過驗證
2.category是可選項,驗證規則是在某個intent-fliter標籤申明了多個標籤的話,則請求驗證的intent的所有category都必須是當前請求驗證的intent-fliter標籤category的子集。
<intent -infliter >
<category android:name=" category 1"/>
<category android:name=" category2"/>
<category android:name=" category3"/>
</intent -infliter ><
eg2:
Intent intent = new Intent();
intent .addCategory("category1");
intent .addCategory("category2");
通過驗證
eg3:
Intent intent = new Intent();
intent .addCategory("category1");
intent .addCategory("category2");
intent .addCategory("category4");
沒有通過驗證
3.data驗證。data的格式 : scheme://host:port/path
3.1:驗證必須是從左至右開始逐個驗證不允許跳躍驗證。
eg:
3.2:scheme是必須要有的。
3.3:驗證的屬性
a android:scheme=""
b android:host=""
c android:port=""
d android:path=""
e android:pathPattern=""
f android:pathPrefix=""
g android:mimeType=""
h android:ssp="" 4.4 plus
i android:sspPattern="" 4.4 plus
j android:sspPrefix="" 4.4 plus
對於a、b、c、d他們的關係是與的關係,只有全部滿足才算通過。
對於d、e、f他們的關係是或的關係,通過任意一個都算通過。
對於uri(a、b、c、d、e、f)和mimeType的關係是與的關係。只有全部滿足才算通過。記住如果請求驗證的的Intent含有uri或者mimeType,而標籤含有uri或mimeType那麼請求驗證是失敗的。反之也失敗的。
4. ssp 見https:/zybuluo.com/flyouting/note/18525
注1:path 是用於完整路徑匹配. eg: /index.jsp
注2:pathPattern是路徑匹配模式有兩種形式 "*" 、 ".*"
*代表的是*前的一個字元有0個或多個。 ab*c匹配 ac abc abbc abbbc
.*代表的是 0個或多個字串。 ab*c匹配 abc abec abffc abuuuuc
注3:pathPrefix是用於路徑首碼匹配. /in 匹配 /in.jsp index.jsp .....
注4:host也可以用萬用字元不過host只能包含一個*的萬用字元,而不能包含其他字元。
android intent-infliter 過濾驗證