android Intent匹配,自定义action data category
来源:互联网 发布:华广软件套餐 编辑:程序博客网 时间:2024/06/05 09:51
官网对Intent的action、data和category的说明
public Intent setAction (String action)Added in API level 1Set the general action to be performed.ParametersactionAn action name, such as ACTION_VIEW. Application-specific actions should be prefixed with the vendor's package name.ReturnsReturns the same Intent object, for chaining multiple calls into a single statement.
public Intent setData (Uri data)Added in API level 1Set the data this intent is operating on. This method automatically clears any type that was previously set by setType(String) or setTypeAndNormalize(String).Note: scheme matching in the Android framework is case-sensitive, unlike the formal RFC. As a result, you should always write your Uri with a lower case scheme, or use normalizeScheme() or setDataAndNormalize(Uri) to ensure that the scheme is converted to lower case.ParametersdataThe Uri of the data this intent is now targeting.ReturnsReturns the same Intent object, for chaining multiple calls into a single statement.
public Intent addCategory (String category)Added in API level 1Add a new category to the intent. Categories provide additional detail about the action the intent performs. When resolving an intent, only activities that provide all of the requested categories will be used.ParameterscategoryThe desired category. This can be either one of the predefined Intent categories, or a custom category in your own namespace.ReturnsReturns the same Intent object, for chaining multiple calls into a single statement.
可以看出action, data, category都是可以自定义的。
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) categoryThe extras and flags play no part in resolving which component receives an intent.
系统根据IntentFilter决定哪个元件可以接收哪个Intent,Intent是否匹配的判定只跟action,data和category有关。
自定义action的官方命名规范:
You can also define your own action strings for activating the components in your application. Those you invent should include the application package as a prefix — for example: "com.example.project.SHOW_COLOR
".
category需要注意的地方
In principle, therefore, an Intent object with no categories should always pass this test, regardless of what's in the filter.
That's mostly true. However, with one exception, Android treats all implicit intents passed to startActivity()
as if they contained at least one category: "android.intent.category.DEFAULT" (the CATEGORY_DEFAULT constant).
Therefore, activities that are willing to receive implicit intents must include "android.intent.category.DEFAULT"
in their intent filters. (Filters with "android.intent.action.MAIN" and "android.intent.category.LAUNCHER" settings are the exception.
They mark activities that begin new tasks and that are represented on the launcher screen.
They can include "android.intent.category.DEFAULT" in the list of categories, but don't need to.)
- android Intent匹配,自定义action data category
- Android Intent Action,Category,Data,Extra,Flag
- Android中Action、Category、Data匹配规则
- Android基础总结十一:intent-filter的action,category,data匹配规则
- intent-filter的action,category,data匹配规则
- intent-filter的action,category,data匹配规则
- android intent中的action data Category、Extras的重要属性
- Android隐式启动Activity匹配详解:Action,category,data
- Android隐式启动Activity匹配详解:Action,category,data
- Android隐式启动Activity匹配详解:Action,category,data
- Android隐式启动匹配:action,category,data
- Android隐式启动匹配:action,category,data
- Intent的属性Action, Category, Extras,Data
- Android开发————Intent中的四个重要属性Action、Data、Category、Extras
- Android中Intent-filter的四个属性Action,Category,Extras,Data
- **android Intent 的Componet ,Action ,Category,Data,Type,Extra,Flag 7种属性详解
- 对于android中Intent的action、category、data的补充说明
- Android:Intent Filter简介及属性(action、Category等)匹配方式说明
- 单例设计模式
- C#开发日志[2013-12-5]创建Bitmap引发"参数无效"异常
- Android 画图方式总结
- 回溯法:N后问题
- Boost asio async_accept memory leak问题分析
- android Intent匹配,自定义action data category
- struts 多语言配置
- (Java)判断回文串,忽略既非字母又非数字的字符
- WordPress中文标签伪静态设置方法,以及为什么出错?
- oracle实现对表dml错误记录日志
- 使用NSOperationQueue简化多线程开发
- 我妈要是知道这些,我早上北大了。
- ubuntu12.04 安装Gearman及其php扩展
- 鼠标经过隐藏图片显示文字