Requesting Runtime permissions on Xiaomi devices

吃可爱长大的小学妹 提交于 2020-01-02 16:23:55

问题


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

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.

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

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

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.


回答1:


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.

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.

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



来源:https://stackoverflow.com/questions/38971610/requesting-runtime-permissions-on-xiaomi-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!