How to use an Image Uri outside Activity?

Viewed 22

I'm creating a Sign-Up page from my app that has the option to obtain an image from the gallery using this code:

Intent pickImageFileIntent = new Intent(Intent.ACTION_PICK);
            pickImageFileIntent.setType("image/*");
            

            String pickTitle = getString(R.string.select_img_gallery);
            Intent chooserIntent = Intent.createChooser(pickImageFileIntent, pickTitle);
            startActivityForResult(chooserIntent, PICK_IMAGE);

After the user selects the image from the gallery I show that image in an ImageView using Glide, and it works fine. But when I try to use that image's Uri in another activity I get permission denied and the app crashes, so I think the Uri only has permissions for the Activity where ti was obtained. I tried to use ACTION_GET_DOCUMENT instead of ACTION_PICK and it works but the problems is in the Intent chooser it only shows the file explorer instead of the default media gallery and Google Photos, like when I use ACTION_PICK. Is there a way to use the Uri outside the activity while still using ACTION_PICK?

0 Answers
Related