Skip to content
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

All About Scope Storage. #146

Closed
rosuH opened this issue Sep 13, 2021 · 1 comment · Fixed by #145
Closed

All About Scope Storage. #146

rosuH opened this issue Sep 13, 2021 · 1 comment · Fixed by #145
Labels

Comments

@rosuH
Copy link
Owner

rosuH commented Sep 13, 2021

Android 11 has been released for one year and more. All docs on the Android official website are still telling that the Scope Storage would be force enabled and the requestLegacyExternalStorage would be ignored.

Target Android 11
If your app targets Android 11, both the WRITE_EXTERNAL_STORAGE permission and the WRITE_MEDIA_STORAGE privileged permission no longer provide any additional access.
https://developer.android.com/about/versions/11/privacy/storage

While the READ_EXTERNAL_STORAGE is allowed. And this is the only permission we request.

If your app hasn't opted out of scoped storage and requests the READ_EXTERNAL_STORAGE permission, users see a different dialog compared to Android 10. The dialog indicates that your app is requesting access to photos and media, as shown in Figure 1.

So we do support Android 10 and Android 11. Just enjoy your coding.


Android 11 发布以来,所有文档都声明分区存储会被强制启用,并且 requestLegacyExternalStorage 标志将失效。此处我们无意讨论实际效果。

但是外部存储的读取权限(READ_EXTERNAL_STORAGE)是可用的,不在分区存储限制范围之内。

所以这个库支持 Android 10 以及 Android 11,请放心使用。

REF:

@rosuH rosuH pinned this issue Sep 13, 2021
@rosuH rosuH added the faq label Sep 13, 2021
@rosuH rosuH linked a pull request Sep 13, 2021 that will close this issue
@rosuH rosuH closed this as completed Sep 13, 2021
@rosuH
Copy link
Owner Author

rosuH commented Feb 13, 2022

After actual testing, user feedback, and combined with the documentation, we found that for Android 11 (API 30) and above:

  1. If target api >= 30, then requestLegacyExternalStorage will be ignored and READ_EXTERNAL_STORAGE permission only allows to read media files (such as images), but not other types of files (such as PDF, etc.). If you are in this situation, it is recommended that you implement your own document access using the SAF framework and not use this library. Another solution is to request MANAGE_EXTERNAL_STORAGE, but please consider using this permission carefully. (How to show PDF files? #152)

  2. If the target api == 29, you must use the requestLegacyExternalStorage feature.


经过实际测试、用户反馈,并且结合文档发现,Android 11 (API 30) 以上的系统中:

  1. 如果 target api >= 30,那么 requestLegacyExternalStorage 会被忽略,READ_EXTERNAL_STORAGE 权限仅允许读取媒体文件(比如图片),而无法读取其他类型的文件(比如PDF等)。如果您处于此种情况,建议自己使用 SAF 框架自行实现文档访问,而不要使用这个库。另一个解决方法是申请 MANAGE_EXTERNAL_STORAGE,不过请您慎重考虑使用此权限。(How to show PDF files? #152)
  2. 如果 target api == 29,必须使用 requestLegacyExternalStorage 标记

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant