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

相关文章
相关标签/搜索