0

我正在尝试获取一些图像的缩略图,但文档非常不清楚origId应该是什么。我有一个简单的方法,它将文件作为参数并返回一个可绘制的缩略图,如下所示:

Bitmap thumbnail = MediaStore.Images.Thumbnails.getThumbnail(mContext.getContentResolver(), Long.parseLong(Uri.fromFile(file).getLastPathSegment()), Thumbnails.MINI_KIND, null); 
BitmapDrawable bd = new BitmapDrawable(mContext.getResources(), thumbnail);
return bd;

但是每当被调用时我都会遇到java.lang.NumberFormatException: Invalid long异常。getThumbnail

那么我应该如何为图像文件获取正确的origId呢?

4

1 回答 1

1

试试这种方式(这对我有用):

Bitmap ThumbImage = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(imagePath), THUMBSIZE, THUMBSIZE);
于 2013-08-20T11:19:58.537 回答