使用Intent.ACTION_PICK具体路径路径、具体、Intent、ACTION_PICK

2023-09-12 03:44:57 作者:待我前途伟大炸飞清华北大

我想使用Android的画廊挑选图像。启动画廊很容易用于这一目的。

I am trying to use Android gallery to pick image. Launching gallery is easy for that purpose

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);

但是,我需要来限制显示在像册具体路径上的设备的图像(即,显示只从一个文件夹图像)。这是可能做到怎么样?

However, I need to limit images that are shown in the gallery to specific path on device (i.e. to show images from single folder only). Is this possible to do and how?

推荐答案

对不起,没有这个是不可能的。

Sorry, no this is not possible.

另外您要使用此意向协议错误。按http://developer.android.com/reference/android/content/Intent.html#ACTION_PICK该协议预计,你把内容:URI的数据设置所需的机械手从选择

Also you are using this Intent protocol wrong. As per http://developer.android.com/reference/android/content/Intent.html#ACTION_PICK this protocol expects that you put the content: URI of the data set you want the picker to select from.

这就是说,你应该考虑ACTION_PICK德precated。现代动作ACTION_GET_CONTENT这是更好的支持;你会发现支持ACTION_PICK参差不齐和不一致的。不幸的是ACTION_GET_CONTENT也没有让你指定的目录中。

That said, you should consider ACTION_PICK deprecated. The modern action is ACTION_GET_CONTENT which is much better supported; you will find support of ACTION_PICK spotty and inconsistent. Unfortunately ACTION_GET_CONTENT also does not let you specify a directory.

 
精彩推荐
图片推荐