问题描述
我试图让用户选择他们自己的设备上要在这种壁纸应用程序,我要建一个壁纸使用任何图像。出于某种原因,当我写:
I'm trying to let the user choose any image that they want on their device to use as a wallpaper in this wallpaper application I'm building. For some reason when I write:
Intent myIntent = new Intent(Intent.ACTION_PICK);
myIntent.setType("image/*");
startActivityForResult(i, 100);
我直接进入画廊,但是当我写的:
I go straight into the gallery, but when I write:
Intent myIntent = new Intent(Intent.ACTION_GET_CONTENT, null);
myIntent.setType("image/*");
startActivityForResult(i, 100);
我从图库,或谷歌驱动器选择。什么是让用户选择什么样的程序来获取每一次画面的最佳方法是什么?或者为什么做这两个不同的意图常量有所作为?
I get to choose from Gallery, or Google Drive. What is the best way to let the user choose what app to retrieve the picture from every time? Or why do those two different intent constants make a difference?
推荐答案
你的第一个意图
是无效的。该协议 ACTION_PICK
要求你提供一个乌里
表示你是从采摘的集合。
Your first Intent
is invalid. The protocol for ACTION_PICK
requires you to supply a Uri
indicating the collection you are picking from.
什么是让用户选择什么样的应用程序来获取每一次画面的最佳方法是什么?
如果您希望用户选择基于MIME类型的东西,使用 ACTION_GET_CONTENT
。
If you want the user to choose something based on MIME type, use ACTION_GET_CONTENT
.
如果你有一些特定集合(标有乌里
),您希望用户挑选,使用 ACTION_PICK
。
If you have some specific collection (identified by a Uri
) that you want the user to pick from, use ACTION_PICK
.
在出现平局,去与 ACTION_GET_CONTENT
。虽然 ACTION_PICK
是没有正式去precated,戴安娜Hackborn建议 ACTION_GET_CONTENT
。
In case of a tie, go with ACTION_GET_CONTENT
. While ACTION_PICK
is not formally deprecated, Dianne Hackborn recommends ACTION_GET_CONTENT
.
这篇关于Intent.ACTION_GET_CONTENT和Intent.ACTION_PICK的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!