I have no clue at why this happens, but I am not able to pick images from the Google Photos provider. Testing on API 27.
With ACTION_GET_CONTENT
If I use:
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.addCategory(Intent.CATEGORY_OPENABLE)
intent.type = "image/*"
- I can see Google Photos among the provider
- I can browse to some picture and select it
- Then I am directed back to the providers list (not to my app), as if the provider had crashed in a try-catch
When I open the Photos provider and navigate through folders I see lots of these:
2019-03-02 12:04:15.164 17641-13395/? W/NetworkManagementSocketTagger: untagSocket(120) failed with errno -22
2019-03-02 12:04:22.528 13217-13217/? E/ResourceType: Style contains key with bad entry: 0x01010586
2019-03-02 12:04:22.535 13217-13217/? W/ResourceType: For resource 0x7f020366, entry index(870) is beyond type entryCount(468)
When I click on the picture, I see these:
2019-03-02 12:04:34.150 13217-13217/? W/ResourceType: For resource 0x7f02036c, entry index(876) is beyond type entryCount(468)
2019-03-02 12:04:34.151 13217-13217/? W/ResourceType: For resource 0x7f02036c, entry index(876) is beyond type entryCount(468)
2019-03-02 12:04:34.229 2907-16891/? W/MediaExtractor: FAILED to autodetect media content.
2019-03-02 12:04:34.569 10839-10839/? W/ResourceType: ResTable_typeSpec entry count inconsistent: given 468, previously 1330
With ACTION_OPEN_DOCUMENT
In this case I don't even see Google Photos in the providers drawer.
Question
How can I solve this, preferably with ACTION_GET_CONTENT?
I had the same problem, I could not get image URI from Google Photos with a
ACTION_GET_CONTENT
intent. The problem was related tolaunchMode
of my activity. I could not find any reference to Android documentations. but this way the problem completely solved:I had a single activity application and my
ACTION_GET_CONTENT
intent was something like this:the problem was
singleInstance
launch mode in activity's definition in AndroidManifest.xml.By removing the android:launchMode line the problem was solved. If your activity needs to be
singleInstance
, creating a dummy activity will be a good solution. here you can start a dummy activity for result and then do your Intent stuff inside itsonCreate
and thensetResult()
for your requested activity:and here is your code in your MainActivity: