什么时候加上android.intent.category.DEFAULT
2013-02-10 10:30
351 查看
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 intentspassed to
if they contained at least one category: "
(the
Therefore, activities that are willing to receive implicit intents must include "
in their intent filters. (Filters with "
and "
settings are the exception. They mark activities that begin new tasks and that are represented on the launcher screen. They can include "
in the list of categories, but don't need to.) See Using
intent matching, later, for more on these filters.)
http://developer.android.com/guide/components/intents-filters.html
意思是说,每一个通过 startActivity() 方法发出的隐式 Intent 都至少有一个 category,就是 "
的 Activity 都应该包括 "
从上面的论述还可以获得以下信息:
1、一个 Intent 可以有多个 category,但至少会有一个,也是默认的一个 category。
2、只有 Intent 的所有 category 都匹配上,Activity 才会接收这个 Intent。
mostly true. However, with one exception, Android treats all implicit intentspassed to
startActivity()as
if they contained at least one category: "
android.intent.category.DEFAULT"
(the
CATEGORY_DEFAULTconstant).
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.) See Using
intent matching, later, for more on these filters.)
http://developer.android.com/guide/components/intents-filters.html
意思是说,每一个通过 startActivity() 方法发出的隐式 Intent 都至少有一个 category,就是 "
android.intent.category.DEFAULT",所以只要是想接收一个隐式 Intent
的 Activity 都应该包括 "
android.intent.category.DEFAULT" category,不然将导致 Intent 匹配失败。
从上面的论述还可以获得以下信息:
1、一个 Intent 可以有多个 category,但至少会有一个,也是默认的一个 category。
2、只有 Intent 的所有 category 都匹配上,Activity 才会接收这个 Intent。
相关文章推荐
- 什么时候加上android.intent.category.DEFAULT
- 什么时候加上android.intent.category.DEFAULT
- 什么时候加上android.intent.category.DEFAULT和LAUNCHER
- 什么时候加上android.intent.category.DEFAULT
- 什么时候加上android.intent.category.DEFAULT
- 什么时候加上android.intent.category.DEFAULT和LAUNCHER
- (转)什么时候加上android.intent.category.DEFAULT和LAUNCHER
- 什么时候加上android.intent.category.DEFAULT
- 什么时候加上android.intent.category.DEFAULT
- 什么时候加上android.intent.category.DEFAULT和LAUNCHER
- 什么时候加上android.intent.category.DEFAULT
- 什么时候加上android.intent.category.DEFAULT
- 什么时候加上android.intent.category.DEFAULT和LAUNCHER
- 什么时候加上android.intent.category.DEFAULT和LAUNCHER
- (转)什么时候加上android.intent.category.DEFAULT和LAUNCHER
- 什么时候加上android.intent.category.DEFAULT和LAUNCHER
- 什么时候加上android.intent.category.DEFAULT和LAUNCHER
- 什么时候要加上 android.intent.category.DEFAULT
- 什么时候加上android.intent.category.DEFAULT和LAUNCHER
- android.intent.category.DEFAULT的目的是什么?