Android 6.0权限.GET_ACCOUNTS [英] Android 6.0 permission.GET_ACCOUNTS

查看:946
本文介绍了Android 6.0权限.GET_ACCOUNTS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用它来获得许可:

I'm using this to get permission:

if (ContextCompat.checkSelfPermission(context, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {

    // Should we show an explanation?
    if (ActivityCompat.shouldShowRequestPermissionRationale(context, Manifest.permission.GET_ACCOUNTS)) {

    } else {
        // No explanation needed, we can request the permission.
        ActivityCompat.requestPermissions(context, new String[]{Manifest.permission.GET_ACCOUNTS}, PERMISSIONS_REQUEST_GET_ACCOUNTS);

        // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
        // app-defined int constant. The callback method gets the
        // result of the request.
    }
}

但是,弹出的权限对话框要求用户访问联系人!?!?

But the pop up dialog for permission asks user for access Contacts!?!?

在Play商店的6.0之前版本中

In pre 6.0 in Play Store with

<uses-permission android:name="android.permission.GET_ACCOUNTS"/>

请求被命名为Identity,并说明我需要它来获取设备帐户.

request is named Identity and explains I need it to get device account.

推荐答案

那是因为权限组.基本上,权限放置在不同的组下,并且如果授予其中一个权限,则将授予该组的所有权限.

That is because of Permission Groups. Basically, permissions are placed under different groups and all permissions from that group would be granted if one of them is granted.

例如.在联系人"下,有写/读联系人和获取帐户,因此当您要求其中任何一个时,弹出窗口都会要求获得联系人"权限.

Eg. Under "Contacts" , there is write/read contacts and get accounts, so when you ask for any of those, the popup asks for Contacts permissions.

通读:每个Android开发人员都必须了解新的Android运行时权限

编辑1

以为我要添加相关的(不是为了获得帐户,而是权限和组)奥利奥更新信息:
来源: https://developer.android.com/about /versions/oreo/android-8.0-changes.html#rmp

Just thought i'l add the related(not to get accounts but permissions and groups) Oreo update info:
source: https://developer.android.com/about/versions/oreo/android-8.0-changes.html#rmp

在Android 8.0(API级别26)之前,如果应用请求了权限 在运行时并授予了权限后,系统也会错误地 授予应用程序属于同一应用程序的其余权限 权限组,并且已在清单中进行了注册.

Prior to Android 8.0 (API level 26), if an app requested a permission at runtime and the permission was granted, the system also incorrectly granted the app the rest of the permissions that belonged to the same permission group, and that were registered in the manifest.

对于针对Android 8.0的应用,此问题已得到纠正.这 仅向应用程序授予它已明确请求的权限. 但是,一旦用户向该应用授予权限,所有后续 该权限组中的权限请求是自动的 授予.

For apps targeting Android 8.0, this behavior has been corrected. The app is granted only the permissions it has explicitly requested. However, once the user grants a permission to the app, all subsequent requests for permissions in that permission group are automatically granted.

这篇关于Android 6.0权限.GET_ACCOUNTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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