问题
I'm retrieving an GoogleAccountCredential object using:
GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(
context, Arrays.asList({ GmailScopes.MAIL_GOOGLE_COM }))
.setBackOff(new ExponentialBackOff())
.setSelectedAccountName(email)
with email being the Gmail account I'm using on the device.
If I retrieve the account name using credential.getSelectedAccountName the result is null.
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.
Why would GoogleAccountCredential.setSelectedAccountName(String) require the Contacts permission? Is it a bug or a feature?
回答1:
"contacts permission group" is required because the get_account permission required for getselectedaccountname is grouped under contacts.
that is according to https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous
来源:https://stackoverflow.com/questions/33272943/googleaccountcredential-setselectedaccountnamestring-not-working-on-android-6