There are three steps in the intent matching process, including Action , category and data matching. If more than one result is matched, the system displays a dialog for the user to select. Such as:
So today we are mainly to explain, How to customize the title of this chooser?
The code is actually simple, as follows:
- intent Intent = new intent ( intent action_get_content
- Intent . SetType ("audio/*");
- startactivity (Intent. Createchooser (Intent, "Select Music");
Maybe a lot of students will wonder in the Createchooser () method,what does Android do?
Let's take a look at the source code for this method:
- public static Span class= "PLN" > intent Createchooser ( intent target charsequence Title ) {
- intent Intent = new intent ( action_chooser
- Intent . PutExtra (extra_intent, target);
- if (title = null ) {
- Intent . PutExtra (extra_title, TITLE);
- }
- return Intent ;
- }
It should be clear to everyone, originally in the Call Createchooser () method, the system has created a new ACTION for the action_chooser Intent, and our original intent as a parameter passed in. The TITLE of the selector is passed in through extra_title .
Android------Intent.createchooser