android api文档:intent阅读笔记

intent是几大组件之间进行通信的组件。可以包含以下几个部分:

component:指明了处理该intent的对象。

Action类似于一个函数名,规定了其他部分的对应用法:

The action largely determines how the rest of the intent is structured — particularly the data and extras fields — much as a method name determines a set of arguments and a return value.

Data就是一个Uri:

In many cases, the data type can be inferred from the URI — particularly content: URIs, which indicate that the data is located on the device and controlled by a content provider Category:一个字符串: A string containing additional information about the kind of component that should handle the intent. Any number of category descriptions can be placed in an Intent object.

category:一个字符串

A string containing additional information about the kind of component that should handle the intent. Any number of category descriptions can be placed in an Intent object.

Extras: 是一组键值对:

Key-value pairs for additional information that should be delivered to the component handling the intent. Just as some actions are paired with particular kinds of data URIs, some are paired with particular extras. . These methods parallel those for Bundle objects

Flags一些常数字

Flags of various sorts. Many instruct the Android system how to launch an activity (for example, which task the activity should belong to) and how to treat it after it's launched (for example, whether it belongs in the list of recent activities). 

不过以上这些组件在解析对应的intent时候,

Only three aspects of an Intent object are consulted when the object is tested against an intent filter:

action  data (both URI and data type)  category

The extras and flags play no part in resolving which component receives an intent.

与之对应的intentFilter,

A filter has fields that parallel the action, data, and category fields of an Intent object. An implicit intent is tested against the filter in all three areas. To be delivered to the component that owns the filter, it must pass all three tests. 

(至于intent和intent filter详细的匹配规则可以参照具体的api文档,尤其是关于data的匹配规则相对复杂:

Since most available data is dispensed by content providers, filters that specify a data type but not a URI are perhaps the most common

 

 

 

posted @ 2013-07-09 11:52  bobo的学习笔记  阅读(219)  评论(0编辑  收藏  举报