i want display image from Gallery to ImageView. in emulator Android 4.2.2, my code can be running as I expected. but when I plug in the smartphone Android 6.0.1 cant be display the Image to ImageView this is my code :
//Open gallery code
private void showFileChooser() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
}
//Set ImageView code
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
filePath = data.getData();
try {
imageView = (ImageView) getActivity().findViewById(R.id.imageView);
bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), filePath);
imageView.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
My question. Is this because of my android version? and how to solve this solution? Thanks