如何知道该应用当前是否具有所有文件访问'是否许可。 Android 11
但是如何验证该应用当前是否已拥有“所有文件访问”权限。我使用此方法询问许可。
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
intent.addCategory("android.intent.category.DEFAULT");
intent.setData(Uri.parse(String.format("package:%s",this.getPackageName())));
startActivityForResult(intent, 2296);
请帮助我解决这个问题:(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在内部内存的根部创建新的虚拟0个bytes文件,然后将其删除。如果两个操作成功,那么您就可以访问。当您无法访问时,您的代码将
投掷异常
(在创建文件中),您可以尝试{} catch(exception e)
(防止应用应用程序崩溃)内部/外部/共享的路径可以从 环境 班级,我首先尝试 /代码>
create new dummy 0-bytes file in root of internal memory and then remove it. if both operations success then you have access. when you won't have access then your code will
throw Exception
(on create-file step), which you cantry{ }catch(Exception e)
(preventing app crash)path for internal/external/shared can be obtained from
Environment
class, I would try at firstgetExternalStorageDirectory
我这样做:
似乎现在有一种更好的方法:
I do it that way:
Seems there is a better way now though:
Environment.isExternalStorageManager()
在您的
subtest.xml
中声明此权限:要询问
manage_external_storage
:onActivityResult
中获取结果在 在这样的android11中;
declare this permission in your
manifest.xml
:for asking
MANAGE_EXTERNAL_STORAGE
:get your result in
onActivityResult
so, basically you can check permission is granted or not in Android11 like this;