没有“联系人"权限的GoogleAccountCredential.setSelectedAccountName(String)在Android 6.0上不起作用 [英] GoogleAccountCredential.setSelectedAccountName(String) not working on Android 6.0 without Contacts permission

查看:98
本文介绍了没有“联系人"权限的GoogleAccountCredential.setSelectedAccountName(String)在Android 6.0上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下方法检索GoogleAccountCredential对象:

I'm retrieving an GoogleAccountCredential object using:

GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(
                context, Arrays.asList({ GmailScopes.MAIL_GOOGLE_COM }))
                .setBackOff(new ExponentialBackOff())
                .setSelectedAccountName(email)

电子邮件是我在设备上使用的Gmail帐户.

with email being the Gmail account I'm using on the device.

如果我使用credential.getSelectedAccountName检索帐户名,则结果为空.

If I retrieve the account name using credential.getSelectedAccountName the result is null.

这仅在运行Android Marshmallow的设备上发生,并且仅在该应用没有联系人"权限的情况下才会发生.一旦我授予联系人"权限,一切都会正常.

This happens only on devices running Android Marshmallow and only if the app does NOT have the Contacts permission. As soon as I grant the Contacts permission everything works.

为什么GoogleAccountCredential.setSelectedAccountName(String)需要联系人"权限?是错误还是功能?

Why would GoogleAccountCredential.setSelectedAccountName(String) require the Contacts permission? Is it a bug or a feature?

推荐答案

联系人权限组"是必需的,因为getselectedaccountname所需的get_account权限被分组在联系人下.

"contacts permission group" is required because the get_account permission required for getselectedaccountname is grouped under contacts.

这是根据 https://developer.android进行的. com/guide/topics/security/permissions.html#normal-dangerous

这篇关于没有“联系人"权限的GoogleAccountCredential.setSelectedAccountName(String)在Android 6.0上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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