关于android 5.0调用系统相册闪退

最近做的一个项目中需要调用本地相册,本以为是一个很简单的要求。但是当我在android5.0上运行的时候打开相册,APP闪退。

Android调用本地相册,Intent.ACTION_GET_CONTENT和 Intent.ACTION_PICK都是打开本地相册的两种意图活动。这两种方法在android5.0以前使用后得到的结果都一样。但是在android5.0之后,这两种打开本地相册的方式有了明显的区别。


用Intent.ACTION_GET_CONTENT打开android5.0的相册时,显示的是文件的形式,点击一个文件夹之后并没有打开显示图片,而是提示APP闪退。而用 Intent.ACTION_PICK,打开android5.0的本地相册显示的是每一张图片可以随时返回图片的URL。

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"             

这是ACTION_PICK的API解释。     大意就是从数据中选着一个item,返回被选中的值。

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 thanACTION_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. An 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. 

API中也解释道和ACTION_PICK的不同,返回的是什么样的数据,不是用户想要选着的具体URl.


虽然API有所解释但在android5.0以前这两个活动的结果是一样的,android5.0后才具体的体现了这两种的区别。所以建议各位如果在有打开本地相册选取图片的时候选着ACTION_PICK活动。 

有知道这两种ACTION在android5.0才存在区别的,请留言告知。 

以上仅是个人观点,有不对的地方情留言改正。


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值