开发者

startActivity with an implicit category-less intent

开发者 https://www.devze.com 2023-02-08 19:38 出处:网络
It seems to me that if startActivity is called with an implicit categoryless intent, only activities with an intent filter specifying the de开发者_如何学Gofault category (android.intent.category.DEFAU

It seems to me that if startActivity is called with an implicit categoryless intent, only activities with an intent filter specifying the de开发者_如何学Gofault category (android.intent.category.DEFAULT) can be launched.

The category is not needed in the intent filter for services if we use startService instead of startActivity.

Does everybody see the same behavior ?

Is it documented somewhere in the Android official documentation ?


I think that is documented.

See http://developer.android.com/reference/android/content/Intent.html:

The categories, if supplied, must all be listed by the activity as categories it handles. That is, if you include the categories CATEGORY_LAUNCHER and CATEGORY_ALTERNATIVE, then you will only resolve to components with an intent that lists both of those categories. Activities will very often need to support the CATEGORY_DEFAULT so that they can be found by Context.startActivity().

My experience is that an category-less activity can be used with startActivity() if the class is explicitly set in the intent, though. In that case, no intent matching is done.

0

精彩评论

暂无评论...
验证码 换一张
取 消