I have a problem: I have a function that brings me the image from the gallery ;but when I select the image, I don\'t get it.
public void funzione(View v){
in
**Put This in Action Listener from where to choose image **
Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, 100);
This second Action Listener
Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, 200);
After Return from a gallery, Result get Through request code **here code is 100 and 200 for both **
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 100 && resultCode == RESULT_OK && data != null){
Uri imageUri=data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
reg_certificate.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
if(requestCode == 200 && resultCode == RESULT_OK && data !=null){
Uri imageUri=data.getData();
try {
Bitmap bitmap= MediaStore.Images.Media.getBitmap(this.getContentResolver(),imageUri);
org_logo.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
}