在小米设备上请求运行时权限 [英] Requesting Runtime permissions on Xiaomi devices

查看:222
本文介绍了在小米设备上请求运行时权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有API级别23+的设备上请求权限时,文档说明您需要请求您需要的每个权限,并且如果您要从权限组请求权限, >您已经有权访问该权限是由系统授予的. 处理权限请求响应

When requesting permissions on devices with API level 23+ the documentation states you need to request each permission you need, and in case you are requesting a permission from a permissions group that you already have access to the permission is granted by by the system. Handle the permissions request response

但是,在将我的应用程序调整为目标API级别23时,我注意到请求一个组代表的权限就足够了-以下对同一组中其他权限的检查将获得 PackageManager.PERMISSION_GRANTED 检查是否具有权限.

However, while adjusting my app to target API level 23 I noted that it is sufficient to request permission for one representative of the group - and the following checks for other permissions from the same group get PackageManager.PERMISSION_GRANTED when checking if has permission.

例如,如果我请求获得 READ_CONTACTS 的许可,然后检查我是否具有 WRITE_CONTACTS 的许可,答案是肯定的.

For example if I requested permission for READ_CONTACTS and then checked if I had permission to WRITE_CONTACTS the answer was yes.

我在 Nexus One Plus 设备上测试了代码更改,并开始发布该应用.

I tested my code changes on Nexus and One Plus devices and started releasing the app.

然后我开始在 Fabric 上看到报告,其中唯一未通过权限处理的设备是 Xiaomi ,问题是如何在这些设备上请求权限.

Then I started seeing reports on Fabric where the only device failing the permissions handling was Xiaomi and the question is how to request permissions on those devices.

推荐答案

解决方案是实际上遵循文档中的准则,并在危险权限组中请求所有权限,而不是要求一个代表. (显然只有清单XML中列出的权限)

The solution is to actually follow the guidelines in the documentation and request all the permissions in a dangerous permissions group instead of asking for one representative. (obviously only the permissions listed in your manifest xml)

在同一组中发出具有多个权限的单个请求时,用户只会看到一个对话框.

When issuing a single request with multiple permissions from the same group the user sees only one dialog.

我知道文档在此处看起来更安全

I know that the documentation states here and this looks like a safer approach

任何权限都可以属于一个权限组,包括普通权限和您的应用程序定义的权限.但是,如果权限很危险,则权限的组只会影响用户体验.您可以忽略该权限组的普通权限.

Any permission can belong to a permission group, including normal permissions and permissions defined by your app. However, a permission's group only affects the user experience if the permission is dangerous. You can ignore the permission group for normal permissions.

但是到目前为止,我仅针对 Xiaomi 实施了针对所有权限的特定请求,而所有其他设备在向一个组请求一个权限时仍能正常工作.

But so far I implemented a specific request for all permissions only for Xiaomi and all other devices are working fine while requesting one permission from a group.

更新: 根据,正确的行为是是在小米中实现的-这是在 Oreo

Update: according to this the correct behavior is the way that was implemented in Xiaomi - and it's a bug that was fixed in Oreo

这篇关于在小米设备上请求运行时权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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