Intent进阶 和 Intent-filter 学习笔记
2012-07-08 14:41
471 查看
?
2,深入Intent的构造和Intent-filter的基础入门
?
componentName
?
Action,category,data简单入门
我感觉,学intent 和 intent-filter把action,category,data搞清楚才算真正的掌握了intent的用法.
Action
如果学过Structs2的同学应该不会陌生,所谓的action就是发送一个特定的请求,然后,由一个符合这个请求的activity响应官方文档中是这么说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. For this reason, it's a good idea to use action names that are as specific as possible, and to couple them tightly to the other fields of the intent. In other words, instead of defining an action in isolation, define an entire protocol for the Intent objects your components can handle.
我简要说下我理解的大义,有错欢迎指出
action 在很大一部分程度上决定你的intent 是如何构建的,特别是还有data,和 额外的一些字段,还有更多的是如何决定方法名,设置数组和返回的参数.由于这个原因,这是一个很好的方法去尽可能的具体的使用action,用action把这些字段紧密的联系在一起.另外,灵活定义你的action,然后把它定义在一个文档中为你的intent对象的组建能够正常处理
渣翻译…可能比谷歌翻译还有烂…有错欢迎指出!!!!!!!!!!!!!
category
要使一个action能够正常运行,category是必不可少的,关于category详细介绍请看开发者文档中的intent and intent-filter这里说下注意的细节和使用.
首先,这句话是很重要的..取之于官方文档
Therefore, activities that are willing to receive implicit intents must include "
android.intent.category.DEFAULT" in their intent filters.
这句话,告诉我们在intent-filter(可以用xml创建也可以用代码创建,这里主要讲xml的创建),必须添加一个
android.intent.category.DEFAULT,至于,不添加会发生什么事…我花了半个小时的排错告诉我是无法运行的
?
?
data
因为就是一些参数的介绍,看官方文档就好了,我是这样理解这个DATA,例如,我们一个Mp3播放器,当我们在任务管理器中点击一个MP3文件,MP3这个文件就是一个data,就会触发我们,在intent-filter匹配这个Mp3,<data />的activity运行..请注意!!!这里给的都是些关键代码片段…
相关文章推荐
- Intent进阶 和 Intent-filter 学习笔记
- Intent进阶 和 Intent-filter 学习笔记
- Intent进阶 和 Intent-filter 学习笔记
- Intent进阶 和 Intent-filter 学习笔记
- android开发艺术探索 学习笔记(三) IntentFilter的匹配规则
- Android 学习笔记12:Intent和Intent-filter,
- Android开发笔记----Activity再学习(生命周期、启动模式、intent-filter)
- 学习笔记3: IntentFilter的匹配规则
- 学习笔记-AndroidManifest intentfilter之category,action
- Adnroid学习笔记:Intent与<intent-filter>的使用
- python学习笔记(九)函数式进阶:使用map、reduce、filter、sorted
- android菜鸟学习笔记10----Intent及<intent-filter>
- 《疯狂Android讲义》学习笔记 -- 使用Intent和IntentFilter进行通信
- (学习笔记) Android Intent相关
- Android编程学习笔记 之 使用Intent实现页面跳转
- Android Activity和Intent机制学习笔记
- SQL学习笔记4:进阶之JOIN and UNION-JOIN,LEFT JOIN,RIGHT JOIN , FULL JOIN and UNION
- 【数据挖掘】【笔记】阅读之机器学习竞赛进阶
- Activity和Intent机制学习笔记
- Shader 学习笔记 ---Looking Through a Filter 过滤器