The method of analyzing intent filter by Android _android

Source: Internet
Author: User

This article illustrates the method of Android parsing intent filter. Share to everyone for your reference. The specific analysis is as follows:

Anonymous Run-time binding makes it important to understand how Android resolves an implicit intent to a particular application component.

As you have seen before, when using startactivity, implicit intent resolves to a single activity. If more than one activity has the ability to perform a given action on a particular data, Android chooses the best boot from these.

The process of deciding which activity to run is called intent parsing. The goal of intent parsing is to find the best possible intent Filter through the following procedure:

1. Android puts the intent filter available in the installed package into a list.

2. Intent filter, which is not associated with the action and the type of intent being resolved, is removed from the list.

①. Action matching refers to intent filter contains a specific action or no specified action. A intent filter has one or more defined actions, and if no one can match the intent specified action, this intent filter is counted as an action matching check failure.

②. The type of match is more stringent. Intent filter must contain all the types defined in the parsed Intent. A intent filter that does not have a specific kind can only match a intent without a species.

3. Finally, the portion of the intent data URI is compared to the intent filter. If the intent filter defines Scheme,host/authority,path or mimetype, these values are compared to the intent URI. Any mismatch will cause intent filter to be removed from the list.

Intent filter without specifying the data value matches all intent data.

①. MimeType is the data type of the data that is being matched. When matching data types, you can use wildcard characters to match subtypes (for example, earthquakes/*). If intent filter specifies a data type, it must match the intent and all matches without the specified data.

②. Scheme is a protocol to the URI part--for example, Http:,mailto:,tel:.

③. Host-name or "Data Authority" is a section between scheme and path in the URI (for example, www.google.com). When matching host names, scheme for Intent filter must also be matched.

④. The data path is immediately after the "Data Authority" (for example,/ig). Path matches only if both scheme and host-name parts match.

4. If more than one component of the process is parsed, they are sorted by priority, and an optional label can be added to the node of intent filter. The highest level components are returned.

The Android local application component, like Third-party applications, is part of the intent parsing process. They have no higher priority and can be completely replaced by new activity, which declares that their intent filter responds to the same action request.

I hope this article will help you with your Android program.

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.