Intents and Intent Filters
Key classes
1. Intent
2. IntentFilter
3. Activity
4. Service
5. BroadcastReceiver
6. PackageManager
本文中将包含以下内容:
1. Intent Objects
2. Intent Resolution
3. Intent filters
4. Common cases
5. Using intent matching
6. Note Pad Example
Three of the core components of an application — activities, services, and broadcast receivers — are activated through messages, called intents. Intent messaging is a facility for late run-time binding between components in the same or different applications. The intent itself, an Intent object, is a passive data structure holding an abstract description of an operation to be performed — or, often in the case of broadcasts, a description of something that has happened and is being announced. There are separate mechanisms for delivering intents to each type of component:
翻译:在Android系统中有三类核心组件 activities, services, broadcast receivers。这些组件都是通过一个称之为intent的消息对象激活的。intent消息对象可以理解是应用程序或应用程序之间组件的链接或绑定工具。intent消息对象本身只是一个抽象数据结构体对象,其中包含的信息是对某种操作的描述。针对所要激活的组件类型的不同,发送相应的intent 对象的方式也分以下三种。(intent这个词我个人理解还是不要翻译出来为好,把它理解成与HttpRequest类似的请求对象既可。)
一、An Intent object is passed to Context.startActivity() or Activity.startActivityForResult() to launch an activity or get an existing activity to do something new. (It can also be passed to Activity.setResult() to return information to the activity that called startActivityForResult().)【翻译:Intent对象作为Context.startActivity() 或 Activity.startActivityForResult()方法的参数,可以在方法执行的时候让系统创建并启动一个activity实例或是使得一个现存的activity实例响应该intent请求,执行相关的操作(Intent对象也是Activity.setResult()方法的参数,该方法与startActivityForResult()方法有前后依赖关系,目标activity可以向源activity返回intent对象的,实际需要的返回值被封装在原始intent实例中被返回)】。
二、An Intent object is passed to Context.startService() to initiate a service or deliver new instructions to an ongoing service. Similarly, an intent can be passed to Context.bindService() to establish a connection between the calling component and a target service. It can optionally initiate the service if it's not already running.
【翻译:Context.startService()方法的参数intent的目的是创建一个服务组件实例或是给一个执行中的服务实例发送指令,同样, Context.bindService()的参数intent的作用是在当前组件与目标服务之间创建一个连接,如果说目标服务没有启动,那么将会创建目标服务组件实例。】
三、Intent objects passed to any of the broadcast methods (such as Context.sendBroadcast(), Context.sendOrderedBroadcast(), or Context.sendStickyBroadcast()) are delivered to all interested broadcast receivers. Many kinds of broadcasts originate in system code.【翻译:intent对象也是众多广播方法如Context.sendBroadcast(), Context.sendOrderedBroadcast(), 或 Context.sendStickyBroadcast()的参数,这个参数同样也是被传递给广播接收组件的,在Android系统代码中,有很多类型的广播接收组件。】
In each case, the Android system finds the appropriate activity, service, or set of broadcast receivers to respond to the intent, instantiating them if necessary. There is no overlap within these messaging systems: Broadcast intents are delivered only to broadcast receivers, never to activities or services. An intent passed to startActivity() is delivered only to an activity, never to a service or broadcast receiver, and so on.
【翻译:以上我们说到的场合,Android系统会查找目标activity或目标service或是相关的那些广播接收器组件来对当前 intent实例做应答,如果说需要,那么系统会创建相应的组件实例,系统在定位目标组件的时候不会出现重复定位的现象,不同类别的目标组件会被严格区分。】
This document begins with a description of Intent objects. It then describes the rules Android uses to map intents to components — how it resolves which component should receive an intent message. For intents that don't explicitly name a target component, this process involves testing the Intent object against intent filters associated with potential targets.
【翻译:该文档开始介绍intent消息对象。同时还将就Android系统对intent实例和目标组件之间的匹配规则以及intent消息对象如何被解析、匹配到一个目标组件的详细过程做描述。尤其针对隐式intent消息对象,对Android系统基于intent过滤器寻找目标组件的匹配测试过程作详细说明。】
Key classes
1. Intent
2. IntentFilter
3. Activity
4. Service
5. BroadcastReceiver
6. PackageManager
本文中将包含以下内容:
1. Intent Objects
2. Intent Resolution
3. Intent filters
4. Common cases
5. Using intent matching
6. Note Pad Example
Three of the core components of an application — activities, services, and broadcast receivers — are activated through messages, called intents. Intent messaging is a facility for late run-time binding between components in the same or different applications. The intent itself, an Intent object, is a passive data structure holding an abstract description of an operation to be performed — or, often in the case of broadcasts, a description of something that has happened and is being announced. There are separate mechanisms for delivering intents to each type of component:
翻译:在Android系统中有三类核心组件 activities, services, broadcast receivers。这些组件都是通过一个称之为intent的消息对象激活的。intent消息对象可以理解是应用程序或应用程序之间组件的链接或绑定工具。intent消息对象本身只是一个抽象数据结构体对象,其中包含的信息是对某种操作的描述。针对所要激活的组件类型的不同,发送相应的intent 对象的方式也分以下三种。(intent这个词我个人理解还是不要翻译出来为好,把它理解成与HttpRequest类似的请求对象既可。)
一、An Intent object is passed to Context.startActivity() or Activity.startActivityForResult() to launch an activity or get an existing activity to do something new. (It can also be passed to Activity.setResult() to return information to the activity that called startActivityForResult().)【翻译:Intent对象作为Context.startActivity() 或 Activity.startActivityForResult()方法的参数,可以在方法执行的时候让系统创建并启动一个activity实例或是使得一个现存的activity实例响应该intent请求,执行相关的操作(Intent对象也是Activity.setResult()方法的参数,该方法与startActivityForResult()方法有前后依赖关系,目标activity可以向源activity返回intent对象的,实际需要的返回值被封装在原始intent实例中被返回)】。
二、An Intent object is passed to Context.startService() to initiate a service or deliver new instructions to an ongoing service. Similarly, an intent can be passed to Context.bindService() to establish a connection between the calling component and a target service. It can optionally initiate the service if it's not already running.
【翻译:Context.startService()方法的参数intent的目的是创建一个服务组件实例或是给一个执行中的服务实例发送指令,同样, Context.bindService()的参数intent的作用是在当前组件与目标服务之间创建一个连接,如果说目标服务没有启动,那么将会创建目标服务组件实例。】
三、Intent objects passed to any of the broadcast methods (such as Context.sendBroadcast(), Context.sendOrderedBroadcast(), or Context.sendStickyBroadcast()) are delivered to all interested broadcast receivers. Many kinds of broadcasts originate in system code.【翻译:intent对象也是众多广播方法如Context.sendBroadcast(), Context.sendOrderedBroadcast(), 或 Context.sendStickyBroadcast()的参数,这个参数同样也是被传递给广播接收组件的,在Android系统代码中,有很多类型的广播接收组件。】
In each case, the Android system finds the appropriate activity, service, or set of broadcast receivers to respond to the intent, instantiating them if necessary. There is no overlap within these messaging systems: Broadcast intents are delivered only to broadcast receivers, never to activities or services. An intent passed to startActivity() is delivered only to an activity, never to a service or broadcast receiver, and so on.
【翻译:以上我们说到的场合,Android系统会查找目标activity或目标service或是相关的那些广播接收器组件来对当前 intent实例做应答,如果说需要,那么系统会创建相应的组件实例,系统在定位目标组件的时候不会出现重复定位的现象,不同类别的目标组件会被严格区分。】
This document begins with a description of Intent objects. It then describes the rules Android uses to map intents to components — how it resolves which component should receive an intent message. For intents that don't explicitly name a target component, this process involves testing the Intent object against intent filters associated with potential targets.
【翻译:该文档开始介绍intent消息对象。同时还将就Android系统对intent实例和目标组件之间的匹配规则以及intent消息对象如何被解析、匹配到一个目标组件的详细过程做描述。尤其针对隐式intent消息对象,对Android系统基于intent过滤器寻找目标组件的匹配测试过程作详细说明。】
发表评论
-
Intents and Intent Filters--Intent filters
2010-09-03 10:21 1361Intent filters To inform ... -
Intents and Intent Filters---Intent Resolution
2010-09-03 09:45 1196Intent Resolution Intents 可以分成 ... -
Intents and Intent Filters---Intent Objects
2010-09-02 11:15 816Intent Objects An Intent ... -
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 1049Service 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 959Component 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 1290Remote procedure calls--远程过程调用 ... -
Application Fundamentals--Processes and Threads(进程与线程)
2010-08-27 09:36 990Processes and Threads--进程 ... -
Application Fundamentals--Starting tasks
2010-08-27 09:34 699Starting tasks An activity is ... -
Application Fundamentals--Clearing the stack(堆栈清理)
2010-08-27 09:28 1344Clearing 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 788Activities 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对象, 它包含了...
本文是android开发中消息机制Intent 理论部分的详细介绍与分析。通过本文会了解android上层各个应用组建是如何通信和发生松散耦合的。
1 意图和意图过滤器Intents and Intent Filters 2 意图对象Intent Objects 3 意图解析Intent Resolution 4 过滤器与安全Filters and security
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 ? 系统偏好:快速...
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 ...
本书主要内容为: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 系统...
意图和意图过滤器Intents and Intent Filters 43 意图过滤器Intent filters 47 通常情况Common cases 51 使用意图匹配Using intent matching 52 数据存储Data Storage 52 概览Storage quickview 52 系统偏好:...
Android-Intents-3 part
Android Espresso测试ui(intents,webviwe ,button等普通view,AdaoterView类型的View)