gpt4 book ai didi

android - "Required permission was denied!"请求 WRITE_EXTERNAL_STORAGE 时

转载 作者:行者123 更新时间:2023-12-04 23:48:00 25 4
gpt4 key购买 nike

我正在尝试在 Android 10 上请求 WRITE_EXTERNAL_STORAGE 权限。我使用以下代码执行此操作:

ArrayList<String> permissions = new ArrayList<>();
if (this.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
permissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
}
if (this.checkSelfPermission(ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
permissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &&
this.checkSelfPermission(ACCESS_BACKGROUND_LOCATION) != PackageManager.PERMISSION_GRANTED) {
permissions.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
}
if (this.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
if (permissions.size() > 0) requestPermissions(permissions.toArray(new String[0]), PERMISSION_REQUEST_FINE_LOCATION);

这是 list
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

除 WRITE_EXTERNAL_STORAGE 外,所有其他权限均有效。当我尝试请求它时,它不会显示任何确认权限的对话框,但它只是拒绝它。为什么以及如何解决?

最佳答案

我已经找到了解决方案,但是问题的原因对我来说仍然是个谜。如果有人有解释,将不胜感激。基本上我的问题是这个 issue 的副本.我所要做的就是将以下行从

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


<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace"/>

tools:node="replace"有什么作用?

关于android - "Required permission was denied!"请求 WRITE_EXTERNAL_STORAGE 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61140976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com