需要许可只对老年人的Andr​​oid版本:maxSdkVersion不起作用? [英] Require permission only for older android versions: maxSdkVersion does not work?

查看:151
本文介绍了需要许可只对老年人的Andr​​oid版本:maxSdkVersion不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有些权限仅用于兼容旧设备。所以我做了一些研究,发现该此处

  

机器人:maxSdkVersion
     最高级别的API,在此权限应给予您的应用程序。如果你的应用程序需要的权限不再需要开始在某一个API级别设置该属性是非常有用的。

     

例如,采用Android 4.4(API级别19)开始,它不再需要为您的应用程序来当你的应用程序要写入外部存储自己的应用程序特定的目录(由getExternalFilesDir提供的目录要求WRITE_EXTERNAL_STORAG​​E许可())。但是,许可,才能进行API级别18和较低。所以,你可以声明此权限只需要达到API级18的声明是这样:

 <使用,许可
     机器人:名称=android.permission.WRITE_EXTERNAL_STORAG​​E
     机器人:maxSdkVersion =18/>
 

我想实现这一点,但没有奏效。所以我建立这个简单的测试:

 <使用,许可
    机器人:名称=android.permission.WRITE_SMS
    机器人:maxSdkVersion =3/>
 

据我了解这种许可应仅被要求与API 1-3级的设备,但我得到这个许可请求即使是API 18设备。难道我错,还是为这个功能坏了?

解决方案

maxSdkVersion 属性是在API层面增加19(的文档应该提到)。 <一href="https://android.googlesource.com/platform/frameworks/base/+/fb0676a902dd1195e3e35790d137bc1b90e390ba"相对=nofollow>参考

  

介绍maxSdkVersion为&LT;使用-许可&GT;

     

这样的应用程序可以自动夕阳的权限请求   在更高版本的操作系统,其中这些权限没有运行时,   不再相关,但也可以报警给用户。一个典型的例子   是WRITE_EXTERNAL_STORAG​​E,这为KLP变得不必要了一个应用程序   使用外部存储卷仅仅为了其自身的大数据的需要,   而不需要多个应用程序之间的实际的文件系统的共享。

     

错误9761041

     

更改ID: I60130af3a108fe4a750c356038a1c8cb897e9c8b (失踪,可以是一个谷歌的内部变化)

看起来像Android 4.4系统仍未命名为KK当时的:)

I want to some permissions only for older devices for compatibility. So I did some research and found 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" />

I tried to implemented that, but it did not work. So I build up this simple test:

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

As far I understand this permission should been only required for devices with the API levels 1-3, but I get this permission request even on a API 18 device. Did I something wrong or is this feature broken?

解决方案

maxSdkVersion attribute was added in API level 19 (docs should have mentioned that). 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)

Looks like Android 4.4 was still not named as KK at that time :)

这篇关于需要许可只对老年人的Andr​​oid版本:maxSdkVersion不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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