關於隱式Intent和IntentFilter

Intent 和 Intent filter
1、一個隱式Intent請求必須要通過三方面的檢查:action、data、category。
2、一條<intent-filter>元素至少應該包含一個<action>,否則任何Intent請求都不能和該<intent-filter>匹配。
3、如果Intent請求的Action和<intent-filter>中某一條<action>(一個<intent-filter>元素中可以包含多條<action>)匹配,那麼該Intent就通過了這條<intent-filter>的動作測試。
4、如果<intent-filter>中沒有包含任何Action類型,那麼無論什麼Intent請求都無法和這條<intent-filter>匹配。
5、如果Intent請求中沒有設定Action類型,那麼只要<intent-filter>中包含有Action類型,這個Intent請求就將順利地通過<intent-filter>的行爲測試。
6、只有當Intent請求中所有的Category與組件中某一個IntentFilter的<category>完全匹配時,纔會讓該Intent請求通過測試,IntentFilter中多餘的<category>(<intent-filter>可以聲明多個<category>)聲明並不會導致匹配失敗。一個沒有指定任何類別測試的IntentFilter僅僅只會匹配沒有設置類別的Intent請求。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章