An image from the Gallery (card sd) can?

Asked 2 years ago, Updated 2 years ago, 126 views

I'm working on a photo selection option on my app. There is a button and an image view in the layout, but if I click the button, it connects to the gallery and you can choose the image. If I select an image, I want it to appear in the image view, but how do I make the gallery float and select an image?

android android-image android-gallery

2022-09-22 22:29

1 Answers

Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(android.provider.MediaStore.Images.Media.CONTENT_TYPE);
intent.setData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, GET_PICTURE_URI);
@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == GET_PICTURE_URI) {
        if (resultCode == Activity.RESULT_OK) { 
            URI uri = data.getData();
        }
    }
}


2022-09-22 22:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.