如 Google+ 所述 https://developers.google.com/+/mobile/android/people#retrieve_profile_information_for_a_signed_in_user
You can use the Plus.AccountApi.getAccountName method to get the user's email address that is associated with the connected account. You must declare the permission in your AndroidManifest.xml to use this method.
要在登录后获取用户电子邮件,您必须编写此代码
final String email = Plus.AccountApi.getAccountName(googleApiClient);
最重要的是在你的 AndroidManifest 文件上写 GET_CONTACTS 权限。 但是当我在 UBER 应用程序上尝试相同的场景时,我注意到他们不会询问 GET_CONTACTS 权限,也不会像我在 UBER 设置屏幕上看到的那样收到用户电子邮件 如何在不询问用户 GET_CONTACTS 权限的情况下获取用户 Google+ 电子邮件。
最佳答案
您可以使用以下代码从Google API 获取用户信息。有关详细信息,您可以引用:https://developers.google.com/identity/sign-in/android/people#before_you_begin
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
GoogleSignInAccount acct = result.getSignInAccount();
String personName = acct.getDisplayName();
String personEmail = acct.getEmail();
String personId = acct.getId();
Uri personPhoto = acct.getPhotoUrl();
关于android - 在没有 GET_CONTACTS 权限的情况下获取 Google+ 电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37788008/