0

I'm trying to get the thumbnails of some images but the documentation is very unclear about what the origId should be. I have a simple method that takes a file as parameter and returns a drawable for thumbnails like this:

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;

But I get a java.lang.NumberFormatException: Invalid long exception whenever getThumbnail is called.

So how should I obtain the correct origId for an image file?

Nima G
  • 6,291
  • 7
  • 44
  • 66

1 Answers1

1

Try this way (this worked for me):

Bitmap ThumbImage = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(imagePath), THUMBSIZE, THUMBSIZE);
KOTIOS
  • 11,234
  • 3
  • 37
  • 64