-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(android): add READ_MEDIA_* permissions for Android 13+ #566
feat(android): add READ_MEDIA_* permissions for Android 13+ #566
Conversation
I enabled test but they will likely fail on Android because it will depend on the platform using Compile SDK 33. The Android should be resolved when cordova-android@12 is released. |
Actually I just retested and it works fine while just requesting one permission at a time (READ_MEDIA_IMAGES), but it fails reading (file.listDir() with folder "DCIM") when trying to request all at once. Might be a syntax mistake in the PR or another issue. Shall I update it or close it? For my own usage, it is enough to request the READ_MEDIA_IMAGES. However, for other users it might not be enough, since it should work with all types of Media. That's why I have tried with this PR to request all needed permissions but obviously it isn't as simple. As you suggested, the better approach for accessing external storage would be to not use the file-plugin at all anymore and rather use (if existing) a cordova plugin using the MediaStore API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes looks fine to me, even if it's just a stopgap...
Removing support for reading external storage altogether is a significant change that will require an official vote. And I think before we can explore that route, we'll need a MediaStore API alternative that can be used, even if it's a third-party plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
So, how about permission to read document like pdf, world and xls from external storage (emulated/0/Download/.....) i tried copyTo but still error ( error code : 1) |
Android has no permission for documents, and by extension doesn't support documents via the file API while working with external storage. Instead you have to use a plugin that interfaces with the native MediaStore API to work with document files. More info on this is noted here. Edit: Extending on this comment, using the media store for accessing the external storage (aka anything inside |
thanks @breautek for quick response, copying file is unseccessful, and this is my code window.resolveLocalFileSystemURL(docPath,function (fileEntry) |
Because you're working with a document file, you can't use a filesystem API. You can use filesystem API for internal storage, but not with files on external storage. It looks like you're attempting to move a PDF document from external storage into internal storage. It will error on reading a document from the external storage path (the Generally speaking interacting with files on external storage requires using a media storage API, which this plugin does not implement. See here for a list of plugins that implements the media store API. I'm locking this thread because an old merged PR is not really a place to ask questions or to provide support. If you have further questions, please use Discussions instead. |
Refer to : https://developer.android.com/about/versions/13/behavior-changes-13