gpt4 book ai didi

android - KitKat 仍然需要 WRITE_EXTERNAL_STORAGE?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:54:13 25 4
gpt4 key购买 nike

documentation 中所述,从 API 级别 19 开始,WRITE_EXTERNAL_STORAGE 权限不应该是必需的。因此,我已将其写入 list :

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

但是,当我运行使用 Google Maps V2 并因此需要访问外部存储的应用程序时,我得到了一个SecurityException:

java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

我正在运行该应用程序的手机是 KitKat (4.4),它的 API 级别为 19。据我了解,该应用程序应该能够在没有许可的情况下正常运行。为什么我还是会收到错误消息?

最佳答案

the WRITE_EXTERNAL_STORAGE permission should not be a requirement starting from API level 19

仅当您在 Context 上使用方法(如 getExternalFilesDir())时,才能获取特定于您的应用程序的外部存储的标准位置。对于其他位置,例如 Environment 上的方法报告的路径,您仍然需要权限。

或者,引用 the documentation that you linked to :

For example, beginning with Android 4.4 (API level 19), it's no longer necessary for your app to request the WRITE_EXTERNAL_STORAGE permission when your app wants to write to its own application-specific directories on external storage (the directories provided by getExternalFilesDir()).

此外,欢迎第三方图书馆出于自身原因要求您拥有此权限。

Why do I get the error anyway?

作为其设置过程的一部分,MapsV2 似乎正在验证您是否拥有权限。这是 MapsV2 的特权。也许他们希望在不需要此许可的有限区域之外使用外部存储。也许他们不是,但未能更新他们代码中的权限检查。 MapsV2 是闭源的,很难对这类事情进行分析。

关于android - KitKat 仍然需要 WRITE_EXTERNAL_STORAGE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29678762/

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