My app is supposed to get a picture from the gallery and display it in an ImageView
, I am getting what I want with all the images EXCEPT the ones I took with my back camera, they show up in the gallery for me to pick and even return the path, but all I get is blankness in my ImageView
.
This is the code:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_PICK);
startActivityForResult(intent, SELECT_PICTURE);
my onActivityResult code is this:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SELECT_PICTURE && resultCode == RESULT_OK && null != data) {
Uri uri = data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), uri);
ImageView iv = (ImageView) getView().findViewById(R.id.iv_foto);
iv.setImageBitmap(bitmap);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
It works with images taken with my front camera.
I haven't tried the app on another phone but if this happens in mine, chances are someone else will have the same problem.