参考:AndroidSDK/docs/reference/android/content/Intent

看到相关代码,对这两个参数的区别有点搞不清。

原文地址请保留http://www.cnblogs.com/rossoneri/p/3985597.html

现在知道的是new Intent(Intent.ACTION_GET_CONTENT, null)必须要setType("type/后缀"),否则会会弹出异常FATAL EXCEPTION:main android.content.ActivityNotFoundException,

ACTION_PICK可以不用setType()。但建议设置一下属性,因为他们都是通过属性来打开相应的应用程序。

专门从文档摘下来说明,放一起比较下,以后再看这方面的说明也方便。就不翻译了。程序猿嘛,总得看的懂英文文档吧。

public static final String ACTION_GET_CONTENT

Added in API level 1

Activity Action: Allow the user to select a particular kind of data and return it. This is different than ACTION_PICK in that here we just say what kind of data is desired, not a URI of existing data from which the user can pick. A ACTION_GET_CONTENT could allow the user to create the data as it runs (for example taking a picture or recording a sound), let them browse over the web and download the desired data, etc.

There are two main ways to use this action: if you want a specific kind of data, such as a person contact, you set the MIME type to the kind of data you want and launch it with startActivity(Intent). The system will then launch the best application to select that kind of data for you.

You may also be interested in any of a set of types of content the user can pick. For example, an e-mail application that wants to allow the user to add an attachment to an e-mail message can use this action to bring up a list of all of the types of content the user can attach.

In this case, you should wrap the GET_CONTENT intent with a chooser (through createChooser(Intent, CharSequence)), which will give the proper interface for the user to pick how to send your data and allow you to specify a prompt indicating what they are doing. You will usually specify a broad MIME type (such as image/* or */*), resulting in a broad range of content types the user can select from.

When using such a broad GET_CONTENT action, it is often desirable to only pick from data that can be represented as a stream. This is accomplished by requiring the CATEGORY_OPENABLE in the Intent.

Callers can optionally specify EXTRA_LOCAL_ONLY to request that the launched content chooser only returns results representing data that is locally available on the device. For example, if this extra is set to true then an image picker should not show any pictures that are available from a remote server but not already on the local device (thus requiring they be downloaded when opened).

Input: getType() is the desired MIME type to retrieve. Note that no URI is supplied in the intent, as there are no constraints on where the returned data originally comes from. You may also include the CATEGORY_OPENABLE if you can only accept data that can be opened as a stream. You may use EXTRA_LOCAL_ONLY to limit content selection to local data.

Output: The URI of the item that was picked. This must be a content: URI so that any receiver can access it.

Constant Value: "android.intent.action.GET_CONTENT"
 

public static final String ACTION_PICK

Added in API level 1

Activity Action: Pick an item from the data, returning what was selected.

Input: getData() is URI containing a directory of data (vnd.android.cursor.dir/*) from which to pick an item.

Output: The URI of the item that was picked.

Constant Value: "android.intent.action.PICK"
 

[Android] ACTION_GET_CONTENT与ACTION_PICK的区别的更多相关文章

  1. android脚步---Itent.ACTION_PICK ,startActivityForResult

    public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(Intent.A ...

  2. Android SingleTask与SingleInstance的区别

    Android SingleTask与SingleInstance的区别 原文地址 现有2个项目,taskA.taskB.taskA负责调用taskB中指定的界面. taskB中有3个界面,a.b.c ...

  3. Xamarin.Form与Xamarin.Android或Xamarin.IOS的区别简述

    Xamarin.Form与Xamarin.Android或Xamarin.IOS的区别简述: 可能刚刚接触Xamarin的人来说,对于这个概念比较的模糊,认为这说的不都是同一个东西吗?事实并不是这样的 ...

  4. Android(四)-JVM与DVM区别

    JVM与DVM区别 1.由来 Android是基于java的既然java已经有了java虚拟机,为什么android还要弄一个DVM了?最重要的就是版权问题,一开始就是用的 JVM,没过多久就被SUN ...

  5. android之Itent.ACTION_PICK Intent.ACTION_GET_CONTENT妙用

    你是不是很多时候,想从弹出的电话本姓名列表中中查找到某个人,然后再获取该人的详细信息呢? 你是不是想选择从弹出的列表中选择一张图片,然后将其进行进一步的操作呢? 如果,你想,那你是不是很像知道,我们应 ...

  6. Android Parcelable和Serializable的区别,androidparcelable

    本文主要介绍Parcelable和Serializable的作用.效率.区别及选择,关于Serializable的介绍见Java 序列化的高级认识. 1.作用 Serializable的作用是为了保存 ...

  7. [android界面]android中src和background区别——前景与背景

    ImageView中XML属性src和background的区别: background会根据ImageView组件给定的长宽进行拉伸,而src就存放的是原图的大小,不会进行拉伸.src是图片内容(前 ...

  8. Android title和actionbar的区别

    我想在一个页面的顶端放入两个按钮,应该用title还是actionbar.他们两个什么区别?分别该什么时候用? 答: android title 是UI上的一小部分,它支持Text和Color,你可以 ...

  9. android:ImageView 和ImageButton的区别

    1.继承不同: java.lang.Object ↳ android.view.View ↳android.widget.ImageView ↳ android.widget.ImageButton ...

随机推荐

  1. 02-02:springboot 整合filter

    1.通过注解扫描完成Filter组件的注册 1.1编写filter (添加拦截的servlet) //@WebFilter(filterName = "FirstFilter",u ...

  2. 利用cygwin创建windows下的crontab定时任务

    要求 必备知识 熟悉基本编程环境搭建. 运行环境 windows 7(64位); Cygwin-1.7.35 下载地址 环境下载 什么是Cygwin Cygwin是一个在windows平台上运行的类U ...

  3. Vue笔记:在项目中使用 SCSS

    背景概述 1. CSS预处理器 css预处理器定义了一种新的编程语言,编译后成正常的CSS文件.为CSS增加一些编程的特性,无需考虑浏览器的兼容问题,让CSS更加简洁,适应性更强,可读性更佳,更易于代 ...

  4. 大数据之presto

    1.概述 Presto是一个分布式SQL查询引擎,用于查询分布在一个或多个不同数据源中的大数据集.presto可以通过使用分布式查询,可以快速高效的完成海量数据的查询.它是完全基于内存的,所以速度非常 ...

  5. LVS持久化与超时时间问题分析

    前言 在上一篇文章<搭建DNS+LVS(keepAlived)+OpenResty服务器(Docker环境)>中,我搭建了dns+lvs+openresty+web集群:先来回顾一下架构图 ...

  6. 并发编程之 Java 三把锁

    前言 今天我们继续学习并发.在之前我们学习了 JMM 的知识,知道了在并发编程中,为了保证线程的安全性,需要保证线程的原子性,可见性,有序性.其中,synchronized 高频出现,因为他既保证了原 ...

  7. .17-浅析webpack源码之compile流程-入口函数run

    本节流程如图: 现在正式进入打包流程,起步方法为run: Compiler.prototype.run = (callback) => { const startTime = Date.now( ...

  8. 在.net中序列化读写xml方法的总结--转载过来学习学习

    原文章地址:http://www.cnblogs.com/fish-li/archive/2013/05/05/3061816.html 首先做个大概的总结,XML包括的元素有XmlElement,X ...

  9. 算法时间复杂度、空间复杂度(大O表示法)

    什么是算法? 计算机是人的大脑的延伸,它的存在主要是为了帮助我们解决问题. 而算法在计算机领域中就是为了解决问题而指定的一系列简单的指令集合.不同的算法需要不同的资源,例如:执行时间或消耗内存. 如果 ...

  10. 使用javacv,解码socket接收的H264码流(byte[]),转为yuv处理,最后再合成转为H264

    其实是一个用java实现录像的功能,还没有实现,但解码和转码已经可以. 1.maven环境,pom.xml配置 1 <properties> 2 <javacpp.version&g ...