Detailed examples of Android implicit intent

Detailed examples of Android implicit intent

preface:

As the name suggests, the implicit intention is to find the most matching component without explicitly setting the activation object. For example, there are five people:

(1)A:170cm (2)B:160cm (3)C:180cm (4)D:190cm (5)E:200cm

If the intention is displayed, if we want to indicate the choice of a, we will say: "I choose A." but if it is implicit intention, we will say: "I want to choose a 170cm person". Although we do not specify the choice of a, we will look for the person with the most matching conditions.

In the intent filter, the matching conditions similar to the "height" condition in the above example are:

(1)action (2)category (3)data:scheme、host、path、type

When the conditions for activating these components are set in the program, the program will find the most matching component, but note: as long as there is a little mismatch, it is a mismatch;

For example:

Core code of implicit intent

First, set the intention filter for an activity in androidmanifest.xml:

The above settings are to set the properties of the activity itself. Next, we need to set the matching conditions in the program:

(1)Intent intent = new Intent(); (2)intent.setAction("...."); (3)intent.addCategory("...."); (4)intent.setData(Uri.parse("...."));// Set the scheme, host and path conditions of data (5) intent.setdataandtype (URI. Parse (""), string type)// At the same time, set the scheme, host, path and type conditions of data (6) startactivity (intent)// Call intent. Addcategory ("Android. Intent. Category. Default");

The above is the detailed explanation of Android implicit intent. If you have any questions, please leave a message or go to the community of this site for communication and discussion. Thank you for reading. I hope it can help you. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>