Intent Resolution
Intents 可以分成两类:
1、Explicit intents (显式intents-指定了目标组件名) designate the target component by its name (the component name field, mentioned earlier, has a value set). Since component names would generally not be known to developers of other applications, explicit intents are typically used for application-internal messages — such as an activity starting a subordinate service or launching a sister activity.【翻译:显式intent通常是用于在一个应用中需要激活某个activity的时候使用。】
2、Implicit intents(隐式intents-没有指定目标组件名) do not name a target (the field for the component name is blank). Implicit intents are often used to activate components in other applications.【翻译:隐式intent通常是在需要激活不同应用之间的某个activity的时候使用。】
Android delivers an explicit intent to an instance of the designated target class. Nothing in the Intent object other than the component name matters for determining which component should get the intent.【翻译:Android系统在判定哪个组件响应一个显式intent的时候,intent实例中的组件名属性是最为关键的匹配判定依据】
A different strategy is needed for implicit intents. In the absence of a designated target, the Android system must find the best component (or components) to handle the intent — a single activity or service to perform the requested action or the set of broadcast receivers to respond to the broadcast announcement. It does so by comparing the contents of the Intent object to intent filters, structures associated with components that can potentially receive intents. Filters advertise the capabilities of a component and delimit the intents it can handle. They open the component to the possibility of receiving implicit intents of the advertised type. If a component does not have any intent filters, it can receive only explicit intents. A component with filters can receive both explicit and implicit intents.
翻译:由于隐式intent没有指定目标组件名,这时候Android系统判定目标组件需要一个不同的匹配判定策略,借助该策略来告知 Android系统哪个最为适合的组件来响应该隐式intent,这个基本的判定策略是把当前intent内容与当前应用的manifest文件中的所有 intent过滤器做比对,intent过滤器的作用是声明某个组件所能响应的隐式intent类型。如果manifest文件中的组件声明中没有定义 intent过滤器,那么该组件只能响应显式intent;如果一个组件声明中定义了intent过滤器,那么该组件既可以响应隐式intent也可以响应显式intent。
Only three aspects of an Intent object are consulted when the object is tested against an intent filter:【翻译:针对隐式intent的判定策略只对intent实例中以下三类特征信息来和相关的过滤器做比对】
action
data (both URI and data type)
category
The extras and flags play no part in resolving which component receives an intent.( 翻译:extras和flags不是Android系统判定哪个目标组件响应隐式intent的依据。)
需要说明的是:显式intent依然是可以使用extras和flags属性来向目标组件传递数据和向Android 系统发送启动、管理目标组件的方式、方法指令的。换句话说,如果你是使用显式intent实例来激活目标组件(如activity)的时候,首先需要给你的intent设置目标组件名或在构造intent实例时候直接指定目标组件类名(称之为显式intent);然后,如果目标组件需要接受数据,就用 intent.putExtra方法设置要传递的数据;如果说你希望进一步通过当前intent实例告知运行环境系统如何创建或管理目标组件实例的话,就使用 intent.setFlags(flags)方法设置相应的控制指令。
Intents 可以分成两类:
1、Explicit intents (显式intents-指定了目标组件名) designate the target component by its name (the component name field, mentioned earlier, has a value set). Since component names would generally not be known to developers of other applications, explicit intents are typically used for application-internal messages — such as an activity starting a subordinate service or launching a sister activity.【翻译:显式intent通常是用于在一个应用中需要激活某个activity的时候使用。】
2、Implicit intents(隐式intents-没有指定目标组件名) do not name a target (the field for the component name is blank). Implicit intents are often used to activate components in other applications.【翻译:隐式intent通常是在需要激活不同应用之间的某个activity的时候使用。】
Android delivers an explicit intent to an instance of the designated target class. Nothing in the Intent object other than the component name matters for determining which component should get the intent.【翻译:Android系统在判定哪个组件响应一个显式intent的时候,intent实例中的组件名属性是最为关键的匹配判定依据】
A different strategy is needed for implicit intents. In the absence of a designated target, the Android system must find the best component (or components) to handle the intent — a single activity or service to perform the requested action or the set of broadcast receivers to respond to the broadcast announcement. It does so by comparing the contents of the Intent object to intent filters, structures associated with components that can potentially receive intents. Filters advertise the capabilities of a component and delimit the intents it can handle. They open the component to the possibility of receiving implicit intents of the advertised type. If a component does not have any intent filters, it can receive only explicit intents. A component with filters can receive both explicit and implicit intents.
翻译:由于隐式intent没有指定目标组件名,这时候Android系统判定目标组件需要一个不同的匹配判定策略,借助该策略来告知 Android系统哪个最为适合的组件来响应该隐式intent,这个基本的判定策略是把当前intent内容与当前应用的manifest文件中的所有 intent过滤器做比对,intent过滤器的作用是声明某个组件所能响应的隐式intent类型。如果manifest文件中的组件声明中没有定义 intent过滤器,那么该组件只能响应显式intent;如果一个组件声明中定义了intent过滤器,那么该组件既可以响应隐式intent也可以响应显式intent。
Only three aspects of an Intent object are consulted when the object is tested against an intent filter:【翻译:针对隐式intent的判定策略只对intent实例中以下三类特征信息来和相关的过滤器做比对】
action
data (both URI and data type)
category
The extras and flags play no part in resolving which component receives an intent.( 翻译:extras和flags不是Android系统判定哪个目标组件响应隐式intent的依据。)
需要说明的是:显式intent依然是可以使用extras和flags属性来向目标组件传递数据和向Android 系统发送启动、管理目标组件的方式、方法指令的。换句话说,如果你是使用显式intent实例来激活目标组件(如activity)的时候,首先需要给你的intent设置目标组件名或在构造intent实例时候直接指定目标组件类名(称之为显式intent);然后,如果目标组件需要接受数据,就用 intent.putExtra方法设置要传递的数据;如果说你希望进一步通过当前intent实例告知运行环境系统如何创建或管理目标组件实例的话,就使用 intent.setFlags(flags)方法设置相应的控制指令。
发表评论
-
Intents and Intent Filters--Intent filters
2010-09-03 10:21 1363Intent filters To inform ... -
Intents and Intent Filters---Intent Objects
2010-09-02 11:15 818Intent Objects An Intent ... -
Intents and Intent Filters---序言
2010-09-01 16:06 874Intents and Intent Filters Key ... -
Application Fundamentals--Processes and lifecycles(进程生命周期)
2010-08-30 09:23 754Processes and lifecycles---进 ... -
Application Fundamentals--Broadcast receiver lifecycle(广播接收组件生命周期)
2010-08-30 09:20 4243Broadcast receiver lifecycle--- ... -
Application Fundamentals--Service lifecycle(服务组件的生命周期)
2010-08-30 09:18 1051Service lifecycle--服务组件的生命周期 A ... -
Application Fundamentals--Coordinating activities(activity实例间协调)
2010-08-30 09:15 966Coordinating activities---activ ... -
Application Fundamentals--Saving activity state(保存activity实例的状态信息)
2010-08-27 10:06 1257Saving activity state--保存activi ... -
Application Fundamentals--Component Lifecycles(组件生命周期)
2010-08-27 09:56 961Component Lifecycles--组件生命周期 A ... -
Application Fundamentals--Thread-safe methods(线程安全方法)
2010-08-27 09:51 1254Thread-safe methods--线程安 ... -
Application Fundamentals--Remote procedure calls(远程过程调用)
2010-08-27 09:41 1291Remote procedure calls--远程过程调用 ... -
Application Fundamentals--Processes and Threads(进程与线程)
2010-08-27 09:36 990Processes and Threads--进程 ... -
Application Fundamentals--Starting tasks
2010-08-27 09:34 701Starting tasks An activity is ... -
Application Fundamentals--Clearing the stack(堆栈清理)
2010-08-27 09:28 1345Clearing the stack--堆栈清理 If th ... -
Application Fundamentals--Launch modes-启动模式
2010-08-27 09:27 1118Launch modes-启动模式 There are fo ... -
Application Fundamentals--Affinities and new tasks
2010-08-27 08:45 979Affinities and new tasks By de ... -
Application Fundamentals--Activities and Tasks
2010-08-27 08:42 789Activities and Tasks As noted ... -
Application Fundamentals--Intent 过滤器
2010-08-27 08:41 921Intent 过滤器 Intent 对象可以显式指定目标组件 ... -
Application Fundamentals--The manifest file
2010-08-27 08:40 788The manifest file Android启动应用程 ... -
Application Fundamentals--Activating components: intents(组件的激活)
2010-08-27 08:38 934Activating components: intents- ...
相关推荐
内含四个pdf文件,分别为 Intent and Intent-filter Intents and Intent Filters理论英文 Intents and Intent Filters理论中文 Intent入门指南 详尽介绍关于android intent
Android Intents and Intent Filters(一) 对应博客地址:http://blog.csdn.net/michael__li/article/details/6947545
Android Intents and Intent Filters(二)源代码 对应博客 http://blog.csdn.net/michael__li/article/details/6950127
Android系列教程之十二:Intents and Intent Filters(三)
Android开发之旅 Intents和Intent Filters(实例部分)(免费)
Android开发之旅 Intents和Intent Filters(理论部分)(免费)
Intents and Intent Filters 三种应用程序基本组件——activity, service和broadcast receiver——是使用称为intent的消息来激活的。Intent消息传递是一种组件间运行时绑定的机制. intent是Intent对象, 它包含了...
1 意图和意图过滤器Intents and Intent Filters 2 意图对象Intent Objects 3 意图解析Intent Resolution 4 过滤器与安全Filters and security
本文是android开发中消息机制Intent 理论部分的详细介绍与分析。通过本文会了解android上层各个应用组建是如何通信和发生松散耦合的。
Android开发之旅:环境搭建及HelloWorld 1 Android开发之旅:HelloWorld项目的目录结构 2 Android开发之旅:android架构 3 Android开发之旅:应用程序...Android开发之旅 Intents和Intent Filters(实例部分) 17
This library wraps Intents with a clean and simple to understand interface for a number of specific use-cases. Sample usage See the sample project in the sample/ folder. Installation Add this into ...
意图和意图过滤器Intents and Intent Filters 43 意图过滤器Intent filters 47 通常情况Common cases 51 使用意图匹配Using intent matching 52 数据存储Data Storage 52 概览Storage quickview 52 ? 系统偏好:快速...
本书主要内容为:Android开发环境搭建、Android SDK介绍、Android应用程序结构剖析,并对Android 中最重要的组件Activity、Intents&Intent Filters&Broadcast receivers、Intent、Service、Content Providers进行了...
意图和意图过滤器Intents and Intent Filters 43 意图过滤器Intent filters 47 通常情况Common cases 51 使用意图匹配Using intent matching 52 数据存储Data Storage 52 概览Storage quickview 52 系统...
Understanding Intents and Intent Filters Chapter 12. Advanced Android Topics BOOK DETAILS Paperback: 960 pages Publisher: Apress; 2nd Edition (December 2012) Language: English ISBN-10: 1430246146 ...
意图和意图过滤器Intents and Intent Filters 43 意图过滤器Intent filters 47 通常情况Common cases 51 使用意图匹配Using intent matching 52 数据存储Data Storage 52 概览Storage quickview 52 系统偏好:...
在撰写本文时,代码示例和文档并未说明如何使用Intent extras开始被测活动。 此模块中包含三个测试类: MainActivityTest :演示使用默认意图运行的基本情况。 MainActivityLaunchIntentTest :演示如...
Android Espresso测试ui(intents,webviwe ,button等普通view,AdaoterView类型的View)