Search code examples
androidandroid-intentkotlingoogle-photos

Unable to pick image from Google Photos app


I'm using the following code (in Kotlin) to select an image from the Google Photos app on my Samsung tablet.

val intent =  Intent (Intent.ACTION_GET_CONTENT)
intent.type = "image/*"
startActivityForResult(intent, REQUEST_GOOGLE_PHOTOS_IMAGE)

I've also tried

Intent (Intent.ACTION_GET_CONTENT,MediaStore.Images.Media.EXTERNAL_CONTENT_URI)

On running this code I get a slideout that allows me to select the Photos app, from which I can then select a photo. However, once I select the photo, the app does not return the image to my app as it does with the camera and gallery. It instead returns to the slideout. When I hit the back button to close the slideout, onActivityResult is called with RESULT_CANCELED and 0 data.

I am able to retrieve photos from the Gallery and the camera without issue so I'm not sure what I'm missing. Maybe a permission or something else in the Manifest? Thanks in advance!


Solution

  • The issue is that I was not connected to the network so Google Photos was unable to retrieve the selected image. See my response to @adityakamble49.