gpt4 book ai didi

android - 仅对较旧的 android 版本 : maxSdkVersion does not work? 需要权限

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

为了兼容性,我只想为旧设备授予一些权限。所以我做了一些研究,发现 this here :

android:maxSdkVersion
The highest API level at which this permission should be granted to your app. Setting this attribute is useful if the permission your app requires is no longer needed beginning at a certain API level.

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()). However, the permission is required for API level 18 and lower. So you can declare that this permission is needed only up to API level 18 with a declaration such as this:

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

我试图实现它,但没有成功。所以我建立了这个简单的测试:

<uses-permission
android:name="android.permission.WRITE_SMS"
android:maxSdkVersion="3" />

据我所知,只有 API 级别 1-3 的设备才需要此权限,但即使在 API 18 设备上我也会收到此权限请求。是我出了什么问题还是这个功能坏了?

最佳答案

maxSdkVersion API 级别 19 中添加了属性(文档应该提到这一点)。 Ref. :

Introduce maxSdkVersion for <uses-permission>

This way an application can automatically sunset its permission requests when running on later versions of the OS where those permissions are no longer relevant, but may be alarming to the user. A canonical example is WRITE_EXTERNAL_STORAGE, which as of KLP becomes unnecessary for an app to use the external storage volume solely for its own large-data needs, without the need for actual file-system sharing among multiple apps.

Bug 9761041

Change-Id: I60130af3a108fe4a750c356038a1c8cb897e9c8b (missing, can be a Google internal change)

看来 Android 4.4 当时还没有命名为 KK :)

关于android - 仅对较旧的 android 版本 : maxSdkVersion does not work? 需要权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20328082/

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