Reputation: 153
I have a Uri of captured image from camera as "file:///storage/emulated/0/Pictures/Colony_Quantifier/IMG_20160523_204353.jpg".
While I am trying to show that image in ImageView, I am not being able to do it no matter whichever options suggested in internet.
Uri uri = Uri.parse("file:///storage/emulated/0/Pictures/Colony_Quantifier/IMG_20160523_204353.jpg");
imgCaptured.setImageURI(uri);
Upvotes: 0
Views: 4967
Reputation: 4891
Try with:
ImageView.setImageURI(Uri.fromFile(new File("/sdcard/cats.jpg")));
Or:
ImageView.setImageURI(Uri.parse(new File("/sdcard/cats.jpg").toString()));
Upvotes: 3
Reputation: 12953
You may use Picasso:
Include this line in your module level build.gradle dependencies:
compile 'com.squareup.picasso:picasso:2.5.2'
then use it as:
Picasso.with(yourContext).load(uri).into(yourImageView);
Upvotes: 2
Reputation: 371
1- You create a Bitmap out of the URI
2- You create a new instance of BitmapDrawable passing in the Bitmap
3- You add the BitmapDrawable to a Window (setBackgroundDrawable), View (setBackgroundDrawable)] or ImageView (setImageDrawable)
Upvotes: 0