Intent resolution

Intent resolution,是指Android系統如何將一個intent請求匹配到一個已經在系統中註冊的組件的(activity,service,broadcast receiver)。根據《Unlocking Android》書中描述,intent解析有兩個最基本的原則:android

一、The action and category must match. ci

二、If specified, the data type must match, or the combination of data scheme and authority and path must match.it

通常狀況下,intent-filter中只要包含action和category就足以知足不少需求。在實際解析過程當中,若是一個組件的intent-filter中沒有聲明任何action,那麼任何intent都能與該組件的action相匹配;可是若是一個intent-filter中沒有聲明任何category,那麼這個組件只能與沒有指定任何category的intent相匹配。須要注意的是:在隱式調用activity時,系統會自動給intent中加入android.intent.category.DEFAULT的category,因此若是一個intent-filter中不聲明Ddefault的category就會致使intent匹配不到任何組件。io

相關文章
相關標籤/搜索