[Apidemos for Android samples video series] app-activity-intents

Source: Internet
Author: User

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

 

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.