我希望在保证兼容性的情况下,仅向部分较旧的设备授予权限。因此,我进行了一些研究,并找到了这个链接:
我试过实现它,但它并没有起作用。因此,我建立了这个简单的测试: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设备上申请此权限。 我做错了什么还是这个功能有问题?
WRITE_EXTERNAL_STORAGE
而不是WRITE_SMS
。 - Pankaj Kumar