我正在尝试从Google+同步照片中的某个文件夹中获取图库应用中的图片.选择图像后,Uri正在正确传回.但是当我试图在存储设备上获取该图像的实际路径时,我可以使用它,它会崩溃.问题似乎与picasa内容提供商有关.
在Nexus S和Nexus 7以及其他设备上进行了测试.
E/AndroidRuntime(14572): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://com.google.android.gallery3d.provider/picasa/item/5427003652908228690 }}
这里,dat字段似乎正确地传递了Uri,但是当我尝试获取图像的位置时,它崩溃时出现以下错误.
W/GalleryProvider(14381): unsupported column: _data
似乎Picasa相册的内容提供商没有_data字段.
获取位置的代码是:
// imageUri is the Uri from above.
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = context.getContentResolver().query(imageUri, proj,null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String filePath = cursor.getString(column_index);
cursor.close();
此图片似乎唯一支持的列包括:[user_account,picasa_id,_display_name,_size,mime_type,datetaken,纬度,经度,方向]
我们如何获得此图像的实际位置.如果我们不应该使用此图像,则不应首先向用户显示这些图像.
启动图库应用程序的意图是:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
我正在尝试使用Android图库来挑选图片.启动画廊很容易实现这一目的
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
Run Code Online (Sandbox Code Playgroud)
但是,我需要将库中显示的图像限制为设备上的特定路径(即仅显示来自单个文件夹的图像).这可能吗?怎么做?