I have ImageView
with image choosen by user from gallery:
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, GALLERY_REQUEST);
and:
@Override
protected void onActivityResult(int reqCode, int resultCode, Intent data) {
super.onActivityResult(reqCode, resultCode, data);
if (resultCode == RESULT_OK) {
try {
final Uri imageUri = data.getData();
final InputStream imageStream = getContentResolver().openInputStream(imageUri);
final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
ImageView img = findViewById(R.id.img);
img.setImageBitmap(selectedImage);
//
ImageURI = Uri.parse(String.valueOf(imageUri));
} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), "Something went wrong", Toast.LENGTH_LONG).show();
}
}else {
Toast.makeText(getApplicationContext(), "You haven't picked Image",Toast.LENGTH_LONG).show();
}
}
Becouse, I need to save Uri of this image to use it later I've created String
ImageURI which value is assigned to String Value of imageUri (as you can see above)
But when I try to load this image to imageview;
ImageView.setImageUri(ImageURI);
image doesn't load. I don;t get any error. Sample Uri which I was using: content://com.miui.gallery.open/raw/%2storage%2Femulated%2F0%2FDCIM%2Camera%2FIMG_20190521_005650.jpg