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
  • 6,383
  • 7
  • 46
  • 68

1 Answers1

1

Try this way (this worked for me):

Bitmap ThumbImage = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(imagePath), THUMBSIZE, THUMBSIZE);
KOTIOS
  • 11,177
  • 3
  • 39
  • 66
  • Yes that works, but I still like to find out what's wrong with my code. – Nima Aug 20 '13 at 11:24
  • hey just check once parameter is ur question statement right according to syntax – KOTIOS Aug 20 '13 at 11:30
  • I think the parameters are all correct, see comment by frienza here: http://stackoverflow.com/a/8383411/558991 – Nima Aug 20 '13 at 11:40