2
我想获得基于缩略图路径的图像路径,我已经尝试了 android-getting-path-to-image-from-thumbnail的解决方案,但它基于gridview位置,我只是检索特定的图像。此外,我找到了一个示例代码SO,代码如何从图像的缩略图路径获取图像路径?
private String getImagePathFromThumbPath(String thumbPath)
{
String imgPath=null;
// String[] projection = new String[] {MediaStore.Images.Thumbnails._ID, MediaStore.Images.Thumbnails.IMAGE_ID};
String[] imagesDataPath={ MediaStore.Images.Media.DATA ,MediaStore.Images.Media._ID};
//mResolver.query() requires android API 16
Cursor thumbnails = mResolver.query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, imagesDataPath,MediaStore.Images.Thumbnails.DATA+"=?",new String[]{thumbPath}, null, null);
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor imageCursor = mResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, filePathColumn, MediaStore.Images.Media._ID + "=?", new String[] {thumbId}, null);
if (imageCursor != null && imageCursor.moveToFirst()) {
// Your file-path will be here
imgPath= imageCursor.getString(imageCursor.getColumnIndex(filePathColumn[0]));
}
return imgPath;
}
地,上述方法有点修改,以适合我的需要,它在祝酒没有返回,请告知如何使用缩略图路径检索的ImagePath?
“EXTERNAL_CONTENT_URI”的用途是什么?是否适用于所有应用程序的内容,因此他们不需要权限?此外,从你的应用程序之外(通过意图)给出一个uri,你怎么知道它的来源(发送它的应用程序),以及它是否有任何额外的信息(所花费的时间等)? – 2014-10-28 12:33:48
我得到的路径,但它的不同的形象。 – Calvin 2015-04-23 13:16:06
@calvin:你传递了什么ID?你确定它有不同的形象吗?如果时间太长,请随时提出另一个问题。 – 2015-04-23 13:35:10