2
我试图从URI(所选择从图片库图片)得到真正的路径,但这个函数总是返回空值:GetRealPathFromUri总是空的结果
//Convert the image URI to the direct file system path of the image file
public String getRealPathFromURI(Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = { MediaStore.Images.Media.DATA };
cursor = getActivity().getContentResolver().query(contentUri, proj, null, null, null);
cursor.moveToFirst();
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
return cursor.getString(column_index);
} finally {
if (cursor != null) {
cursor.close();
}
}
}
那么有没有什么方法可以只显示设备上可用的图像? – Chlebta 2014-11-25 09:47:31
我不相信我见过这个选项。我相信如果你想强加这个限制,唯一的办法就是创建你自己的“照片选择”。但请,如果您找到了一种方法,请与我们分享。 – Budius 2014-11-25 09:51:59
现在我是gona使用你的解决方案,因为我没有太多时间,但将来我会尽力做到这一点,并分享它。我也可以收到你的邮件吗? – Chlebta 2014-11-25 10:01:12