Android: Get thumbnail of image on SD card, given Uri of original image

后端 未结 6 1445
感动是毒
感动是毒 2020-11-29 04:24

So i\'ve got a Uri of an image the user chooses out of images off his SD card. And i\'d like to display a thumbnail of that image, because obviously, the image could be huge

6条回答
  •  鱼传尺愫
    2020-11-29 04:56

    A few trying I could not get the thumbnail path of image from SD. i am resolved this problem getting an android image bitmap, before I create an image view in adapter for gridview (or where you need). So i call method imageView.setImageBitmap(someMethod(Context context, imageID))

    Bitmap someMethod(Context context, long imageId){
    
        Bitmap bitmap =   Media.Images.Thumbnails.getThumbnail(context.getAplicationContext.getContentResolver(), imageid, MediaStore.Images.Thumbnails.MINI_KIND, null);
        return bitmap;
    }
    

    You can get image ID from your SD using this guide (Get list of photo galleries on Android)

提交回复
热议问题