0

I'd like to get an image content from system gallery and put it in an imageview in the FragmentActivity. I'm trying to do so with an implicit intent, however I don't get any data in onActivityResult method. My code:

 chooseFolder.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(intent, PICK_IMAGE_REQUEST);
        }
    });

and when i used the startAactivityForResult

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == PICK_IMAGE_REQUEST) {
        Bitmap image = (Bitmap) data.getExtras().get("data");
        ImageInput.setImageBitmap(image);
    } else if (resultCode == PICK_CAMERA_REQUEST) {
        Uri imageUri = data.getData();
        Picasso.get().load(imageUri).into(ImageInput);
    }
}

this is what i get and no image showing up on my imageview is there something wrong in my code?

Nicola Gallazzi
  • 7,897
  • 6
  • 45
  • 64
Appem
  • 295
  • 1
  • 3
  • 16
  • Possible duplicate of [android pick images from gallery](https://stackoverflow.com/questions/5309190/android-pick-images-from-gallery) – Nicola Gallazzi Mar 05 '19 at 15:24
  • 1
    There is nothing wrong with your code. This code will work fine below `SDK 24` you need to use content provider for devices greater than that. P.S: After you setup content provider you need to convert the content URI to absolute path if you want to use it in picasso. Hope this helped! – Naveen Niraula Mar 05 '19 at 15:43

0 Answers0