) When Will Android. Intent. Category. Default and launcher be added?

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 startedFor example, the following JavaCode:
Intent intent = new intent (this, B. Class)

Implicit intent does not explicitly specify the activity to startInstead, you can set some intent filters to enable the system to filter the appropriate acitivity.

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 will add a category_default by default. In this way, if the category Android. Intent. Category. Default is not included in the intent filter, the matching test will fail. Therefore, if your 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.

Android. Intent. Category. LauncherWhat is the specific function? There is no difference between adding or not in XML. Who can explain it!











One applicationProgramThere can be multiple activities, each of which is at the same level. Which activity is the first to start when a program is started? Some programs may need to be displayed in the program list, while others do not. How to define it? Android. Intent. Action. Main determines the activity Android. Intent. Category. launcher that the application first starts to determine whether the application is displayed in the program list.

Because your program may have many activities
As long as the xml configuration file contains such an intent-filter and the launcher, this activity is the first activity to run when you click the program.

Now you only have one activity, so it does not matter if you do not add it.

Used to set the activity to be enabled by default when the simulator is started.


Related Article

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.