Android. Intent. Category Parsing

Source: Internet
Author: User

1. To solve this problem, you must first understand what is implicit (hidden) intent and what is explicit (explicit) intent.

Explicit intent explicitly specifies the acitivity to be started, such as the following Java code:

Intent intent = new intent (this, B. Class)

Implicit intent does not explicitly specify the activity to be started, but sets some intent filters to let the system filter the appropriate acitivity to start.

2. Which activity does intent send? Three matches are required. One is action, the other is category, and the other is data.

Theoretically, if the intent does not specify the category, the content of the intent filter should match everything. However, if it is implicit intent, Android adds a category_default to it. In this way, if the category Android. Intent. Category. Default does not exist in the intent filter, the matching test will fail. So, if your
If the activity supports receiving implicit intent, you must add Android. Intent. Category. default to the intent filter.

The exception is that android. Intent. Category. Main and Android. Intent. Category. launcher do not need to be added to the filter of Android. Intent. Category. Default. Of course, it is no problem to add the filter.

If the defined activity accepts implicit intent, the android. Intent. Category. Default category must be added to intent filer.

 



Explanation from another article:

When I wrote androidmanifest. XML, I never figured out when to filter activityandroid. Intent. Category. default.

--------------------------------------------------------------------------------

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

--------------------------------------------------------------------------------

It means that each implicit intent sent by startactivity () method has at least one category, which is "android. intent. category. default ", so any activity that wants to receive an implicit intent should include" android. intent. category. default "category. Otherwise, intent matching fails.

The following information can also be obtained from the above discussion:

1. An intent can have multiple category items, but at least one of them is the default category.

2. The activity receives the intent only when all intent category matches.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.