Android Technology--intent Filter

Source: Internet
Author: User

1. To register an activity or service as a handler that accepts implicit intent, a intent-filter tag needs to be added to its manifest node.

2. The intent-filter tag contains attributes:

Intent-filter contains three major attributes of Action,category,data. When an implicit intent is published, these properties will match the intent, and the matching result will determine which handler will be called.

2.1 Action

Each intent filter must contain at least one action tag. The Android:name property of the action specifies the name of the action to be processed. This name should be the only descriptive string, and the recommended practice is to name the action using the Java Package name convention.

2.2 Category (categories)

The category uses the Android:name property to specify under what conditions the service is served for intent. Each Intent filter can have multiple category labels. You can either specify your own category or use the standard values provided by Android.

These standard values are:

LAUNCHER: The activity that listens to this intent filter appears in the launcher of the application.

HOME: The handler for this intent filter can be used as an option on the local screen.

Browsable: The handler that listens to this intent filter will be able to handle an action from within the browser.

Alternative: Provides the default action for a specific action.

Selected_alternative:

2.3 Data

The implicit intent is used to match the data types of the Intent-filter, which have the following data types:

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

For example, when we click on a download link, whether to trigger the browser or trigger the Thunderbolt download software, this is the data tag to achieve.

3. Intent-filter matching Process

When using an implicit intent to start a possible handler, this intent will have a matching process with all intent-filter that have been registered with the Android operating system. This matching process will identify the most appropriate handler to handle this implicit intent.

Step1: The action name of the implicit intent must be the same as the action name of Intent-filter, or the match fails

Step2: The category of an implicit intent can only be a subset of Intent-filter, otherwise the match fails

The data inside the Step3:data must be exactly the same, or the match fails

STEP4: If there are multiple handlers intent-filter that match the implicit intent at the same time,

Android Technology--intent Filter

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.