Skip to content

Commit

Permalink
Merge pull request #755 from DexerBR/patch-3
Browse files Browse the repository at this point in the history
Fixes error when selecting a file from the `Documents` option in newer Android APIs
  • Loading branch information
akshayaurora committed Jul 14, 2023
2 parents 5bd3807 + da41ed2 commit d94d5f9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plyer/platforms/android/filechooser.py
Expand Up @@ -62,6 +62,7 @@
IMedia = autoclass('android.provider.MediaStore$Images$Media')
VMedia = autoclass('android.provider.MediaStore$Video$Media')
AMedia = autoclass('android.provider.MediaStore$Audio$Media')
Files = autoclass('android.provider.MediaStore$Files')
FileOutputStream = autoclass('java.io.FileOutputStream')


Expand Down Expand Up @@ -294,6 +295,11 @@ def _handle_media_documents(uri):
uri = VMedia.EXTERNAL_CONTENT_URI
elif file_type == 'audio':
uri = AMedia.EXTERNAL_CONTENT_URI

# Other file type was selected (probably in the Documents folder)
else:
uri = Files.getContentUri("external")

return file_name, selection, uri

@staticmethod
Expand Down

0 comments on commit d94d5f9

Please sign in to comment.