Android: Intent matches action, category and data principles, androidintent

Source: Internet
Author: User

Android: Intent matches action, category and data principles, androidintent

1. When you define one or more actions in androidmanifest

When you use an implicit intent for other activities or services, it is required that the action in your implicit intent must match the action defined in XML. You can only match one XML file.

2. When you define one or more category in androidmanifest

Indicates that no category is available in your code, but the "android. intent. category. DEFAULT" clause must be added to the XML file.

If you define one or more category items in the code, you must be the same as that defined in the XML file. For example, if you have defined a category, you must match one in the XML file. If you have defined multiple category

Match All in the XML file one by one!

3. When you define one or more data in androidmanifest

Required that the intent must contain data, and the data can fully match a data in the XML file. note that although no URL is specified in the XML file, the default URL is "file and content"

Therefore, we need to write intent. setDataAndType (Uri. parse ("file: // abc"), "data") in the code ");

Finally, android must be added to both action, category, and data in XML. intent. category. DEFAULT, because when you start the activity, it will add it to you by DEFAULT, but if you do not find it in XML, an error will be reported and the matching fails.

If action, category, and data are set at the same time, they must all be correctly matched.

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.