android - 在没有 GET_CONTACTS 权限的情况下获取 Google+ 电子邮件

标签 android permissions

如 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/

相关文章:

Android GoogleMap v2 被裁剪或未完全显示

php create_directory 权限被拒绝 : when attempting shell_exec script

linux - 验证 GTK 应用以 root 权限运行

Android INSTALL_PACKAGES 权限和非 PlayStore 应用

android - 发布Android Market中的应用程序

php - 我正在使用 php 作为后端在 android 中进行推送通知。如何将我的 Sql 数据库值检索到 android 中

android - 非法参数异常 : No view found for id for fragment when trying to setView

android - 如何使用 Google Play 游戏服务获取实时多人游戏参与者的个人资料图像

shell - hdfs 权限被拒绝

php - 无法在 Windows 上打开由 PHP 应用程序生成的文件