Android technology-Intent Filter

Source: Internet
Author: User

Android technology-Intent Filter

1. To register an Activity or Service as a processing program that accepts the implicit intent, you must add an intent-filter tag to its manifest node.

2. Attributes contained in the intent-filter Tag:

Intent-filter contains three attributes: action, category, and data. When an implicit intent is released, these attributes will match the intent, and the matching result will determine which (some) handler will be called.

2.1 action

Each Intent Filter must contain at least one action tag. The android: name attribute of Action specifies the name of the Action to be processed. This name should be a unique descriptive string. We recommend that you use the java package name convention to name Action.

2.2 category (category)

Category uses the android: name attribute to specify the conditions in which services are provided for intent. Each Intent Filter can have multiple category tags. You can specify your own category or use the standard value provided by Android.

These standard values are:

LAUNCHER: the Activity that listens to this Intent Filter will appear in the app LAUNCHER.

HOME: the handler that listens to this Intent Filter can be used as an option on the local screen.

BROWSABLE: the handler that listens to this Intent Filter can process an action from inside the browser.

ALTERNATIVE: Provides default actions for specific actions.

SELECTED_ALTERNATIVE:

2.3 data

Implicit intent is used to match the data types of intent-filter. These data types include:

Android: host, android: mimetype, android: path, android: port, android: scheme

For example, when we click a download link, whether the browser or thunder download software is triggered is implemented by the data tag.

3. intent-filter matching process

When you use an implicit intent to start a possible processing program, this intent will match with all intent-filters that have been registered in the Android operating system. This matching process will find the most appropriate handler to handle this implicit intent.

Step 1: The action name of the implicit intent must be the same as the action name of the intent-filter; otherwise, the matching fails.

Step 2: the category of the implicit intent can only be a subset of the intent-filter; otherwise, the matching fails.

Step 3: the data in the data must be exactly the same one by one; otherwise, the matching fails.

Step 4: If the intent-filter of multiple processing programs matches the implicit intent at the same time,

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.