Android 11 打开失败:EACCES(权限被拒绝) [英] Android 11 open failed: EACCES (Permission denied)

查看:162
本文介绍了Android 11 打开失败:EACCES(权限被拒绝)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序.我将不同的文件类型(例如 docx、pdf、zip)上传到 WAMP 服务器.以下是我的内部存储的文件路径.

I am developing an app. In which I am uploading different file types (e.g. docx, pdf, zip) to a WAMP Server. Below is path of file to my internal Storage.

/storage/emulated/0/WhatsApp/Media/WhatsApp Documents/api.txt

/storage/emulated/0/WhatsApp/Media/WhatsApp Documents/api.txt

我已在清单文件中添加并允许存储权限,并在运行时读取文件.但是没有可用的内部存储权限请求.

I have added and allowed storage permission in Manifest file and also on runtime for reading a file. However there is no Internal Storage Permission request available.

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

而且对于 Android 10 我也使用了这个属性

and also for Android 10 I was using this attribute also

android:requestLegacyExternalStorage="true"

但是当我从内部存储读取文件以进行上传时,我在 Android 11 操作系统(即三星 Galaxy 板载 Android R)上收到此错误.

But i am getting this error on Android 11 OS a.k.a Android R onboard Samsung Galaxy when I am reading file from Internal Storage for uploading.

java.io.FileNotFoundException:/storage/emulated/0/WhatsApp/Media/WhatsApp Documents/api.txt:打开失败:EACCES(权限被拒绝)

java.io.FileNotFoundException: /storage/emulated/0/WhatsApp/Media/WhatsApp Documents/api.txt: open failed: EACCES (Permission denied)

推荐答案

您可以尝试在应用程序标签中使用 manifest 文件中的 android:preserveLegacyExternalStorage="true" 标签.此标签用于访问 android 11 设备中的存储.有关更多详细信息,请点击此链接,它将根据您的要求向您解释更多.

You can try to use the android:preserveLegacyExternalStorage="true" tag in the manifest file in the application tag. This tag is used to access the storage in the android 11 devices. And for more detail follow this link it will explain you more as per your requirement.

我搜索了很多时间并获得了在清单文件中添加 <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE> 的解决方案并尝试获取android 11手机中的文件访问权限.然后您将打开并从存储中读取文件.

I search a lot of time and get the solution that adds <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/> in the manifest file and try to get the file access permission in the android 11 phones. Then you will open and read the file from the storage.

但问题是 Play 商店不允许您在应用中使用 MANAGE_EXTERNAL_STORAGE 权限.允许开发人员使用它来访问所有文件需要时间.这里是链接

But the thing is that the play store does not allow you to use of the MANAGE_EXTERNAL_STORAGE permission in your app. it will take time to give access to the developer to use it to access all the files. Here the link is

这篇关于Android 11 打开失败:EACCES(权限被拒绝)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆