1. Preface
The analysis of this demo is based on the analysis of the API demos of mapdigit.ArticleI further analyzed related knowledge points based on him.
2. Demo Effect
3. Demo Analysis
This example is very simple. There is only one function, that is, to search all the audio files, just go to the topic:
First look at the layout. After entering this example, there is only one textview and one button standing:
After you click "get music", all audio files in the current device are searched and displayed in the list. You can click a song to listen to the audio files, the "OK" and "cancel" buttons in the bottom bar are described as follows:
LayoutCodeWe will not look at it. It is very simple that there is only one button, mainly look at the implementation of the button listener, the Code is as follows:
Private onclicklistener mgetmusiclistener = new onclicklistener () {public void onclick (view v) {intent = new intent (intent. action_get_content); intent. settype ("audio/*"); startactivity (intent. createchooser (intent, "Select music "));}};
Intent is familiar to everyone and its role is to activate the application.ProgramActivities, broadcasts, services, intent itself is a data structure that contains the abstract descriptions of executed operations. Intent aims to find a component that can correctly respond to the intent object description. In this example, the intent object uses
Public intent (string action)
This constructor, and
Intent. action_get_content
A string variable describes an action that can be correctly returned to the component described by intent. This action description should appear in the Action Description of the target component:
<Intent-filter Android: Label = "@ string/xxxx"> <action Android: Name = "android. Intent. Action. get_content"/> </intent-filter>
4. Video Explanation: http://www.eyeandroid.com/thread-9861-1-1.html
5. We learned this demo:
1. Intent. action_get_content usage
Http://www.eyeandroid.com/thread-9812-1-1.html
2. itent. action_pickintent.action_get_content for Android
Http://www.eyeandroid.com/thread-9813-1-1.html