【起航计划 021】2015 起航计划 Android APIDemo的魔鬼步伐 20 App->Intents createChooser
Intents 这个例子的代码非常简单:
public void onGetMusic(View view) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("audio/*");
startActivity(Intent.createChooser(intent, "Select music"));
} public void onGetImage(View view) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivity(Intent.createChooser(intent, "Select image"));
} public void onGetStream(View view) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
startActivity(Intent.createChooser(intent, "Select stream"));
}
它使用了Intent.ACTION_GET_CONTENT 和 MIME 类型来查找支持audio/* 的所有Data Picker ,允许用户选择其中之一。
比如对于Email应用,允许用户选择某种数据文件作为附件。
方法createChooser 提供了创建一个ACTION_CHOOSER Intent的便捷方法。
下图是在模拟器上运行的结果,支持Audio/* MIME 的有两个:
【起航计划 021】2015 起航计划 Android APIDemo的魔鬼步伐 20 App->Intents createChooser的更多相关文章
- 【起航计划 002】2015 起航计划 Android APIDemo的魔鬼步伐 01
本文链接:[起航计划 002]2015 起航计划 Android APIDemo的魔鬼步伐 01 参考链接:http://blog.csdn.net/column/details/mapdigitap ...
- 【起航计划 037】2015 起航计划 Android APIDemo的魔鬼步伐 36 App->Service->Remote Service Binding AIDL实现不同进程间调用服务接口 kill 进程
本例和下个例子Remote Service Controller 涉及到的文件有RemoteService.java ,IRemoteService.aidl, IRemoteServiceCallb ...
- 【起航计划 031】2015 起航计划 Android APIDemo的魔鬼步伐 30 App->Preferences->Advanced preferences 自定义preference OnPreferenceChangeListener
前篇文章Android ApiDemo示例解析(31):App->Preferences->Launching preferences 中用到了Advanced preferences 中 ...
- 【起航计划 027】2015 起航计划 Android APIDemo的魔鬼步伐 26 App->Preferences->Preferences from XML 偏好设置界面
我们在前面的例子Android ApiDemo示例解析(9):App->Activity->Persistent State 介绍了可以使用Shared Preferences来存储一些状 ...
- 【起航计划 020】2015 起航计划 Android APIDemo的魔鬼步伐 19 App->Dialog Dialog样式
这个例子的主Activity定义在AlertDialogSamples.java 主要用来介绍类AlertDialog的用法,AlertDialog提供的功能是多样的: 显示消息给用户,并可提供一到三 ...
- 【起航计划 012】2015 起航计划 Android APIDemo的魔鬼步伐 11 App->Activity->Save & Restore State onSaveInstanceState onRestoreInstanceState
Save & Restore State与之前的例子Android ApiDemo示例解析(9):App->Activity->Persistent State 实现的UI类似,但 ...
- 【起航计划 003】2015 起航计划 Android APIDemo的魔鬼步伐 02 SimpleAdapter,ListActivity,PackageManager参考
01 API Demos ApiDemos 详细介绍了Android平台主要的 API,android 5.0主要包括下图几个大类,涵盖了数百api示例:
- 【起航计划 035】2015 起航计划 Android APIDemo的魔鬼步伐 34 App->Service->Local Service Controller
Local Service Controller 是将LocalService当作“Started”Service来使用,相对于”Bound” Service 来说,这种模式用法要简单得多,Local ...
- 【起航计划 034】2015 起航计划 Android APIDemo的魔鬼步伐 33 App->Service->Local Service Binding 绑定服务 ServiceConnection Binder
本例和下列Local Service Controller 的Activity代码都定义在LocalServiceActivities.Java 中,作为LocalServiceActivities ...
随机推荐
- C++11 特性:成员函数引用限定 (Reference qualifier)
学了这么多年C++今天拜读scott meyes的more effective cpp第一次看到这种写法... 引用限定可以让成员函数只能被左值对象调用或者只能被右值对象调用: #include &l ...
- Kbuild、Kconfig、make menuconfig、.config、Makefile之间的关系
今天突发奇想,想在这里分享下比喻分析Kbuild ---->去饭店吃饭的过程. 1.Kconfig --->饭店的菜单 2.条件编译选项--->菜单中的每一盘菜,可以选择这个菜的 ...
- Java内存区域与内存溢出异常---运行时数据区域
运行时数据区域 Java虚拟机所管理的内存将会包括以下几个运行时数据区域 线程私有区域 1.程序计数器 程序计数器记录的是当前正在执行的虚拟机字节码指令所在的地址.在虚拟机的概念模型中,字节码解释 ...
- SP2713 GSS4 - Can you answer these queries IV
题目大意 \(n\) 个数,和在\(10^{18}\)范围内. 也就是\(\sum~a_i~\leq~10^{18}\) 现在有两种操作 0 x y 把区间[x,y]内的每个数开方,下取整 1 x y ...
- HTTP Status 500 - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
HTTP Status 500 - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.e ...
- winfom实现关闭后一直运行
using PLog; using System; using System.Collections.Generic; using System.Diagnostics; using System.L ...
- [转]Groovy One Liners to Impress Your Friends
Link:http://arturoherrero.com/2011/06/04/10-groovy-one-liners-to-impress-your-friends/ I find that c ...
- DataGrip 使用--方法-..../
tip1: 关键字 自动 大写--
- 读经典——《CLR via C#》(Jeffrey Richter著) 笔记_new新建对象
CLR使用 new 操作符来创建新对象,例如:Employee e=new Employee("Param1"); 以下是 new 操作符所做的事情. 它计算类型及其所有基类型 ...
- A. The number of positions
A. The number of positions time limit per test 0.5 second memory limit per test 256 megabytes input ...