android - 谷歌登录不显示具有单个谷歌帐户的设备的帐户选择器

标签 android google-plus google-signin

我正在尝试为 Android 应用程序实现 google plus 登录。我遵循了谷歌开发者页面“https://developers.google.com/+/mobile/android/getting-started”上的指南。我唯一的问题是,当设备上只有一个谷歌帐户时,不会显示帐户选择器对话框。有解决办法吗?

Google Plus Account Picker

最佳答案

我按照@acj 的建议使用了AccountPicker。我开始一个 AccountPicker Intent

Intent intent = AccountPicker.newChooseAccountIntent(null, null,
                new String[] { "com.google" }, true, null, null, null,
                null);
        startActivityForResult(intent, ACCOUNT_PICKER_REQUEST_CODE);

当返回结果时,我初始化 GoogleApiClient,按照开发者页面上的说明设置 accountName:

GoogleApiClient client = new GoogleApiClient.Builder(this)
     .addApi(Plus.API)
     .addScope(Plus.SCOPE_PLUS_LOGIN)
     .setAccountName("users.account.name@gmail.com")
     .build();
client.connect();

@dcool,希望这有帮助。

关于android - 谷歌登录不显示具有单个谷歌帐户的设备的帐户选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19184652/

相关文章:

javascript - 在网络上启用 Google 帐户选择器

html - 如何从谷歌登录API中提取电子邮件ID?

java - 使用 Retrofit 从服务器获取信息并将所需数据分配给 Spinner

android - 在 Android 中,是否可以在两个单独的应用程序之间安全地共享登录( session )信息?

javascript - Google+ 按钮删除右侧的可用空间/边距 |右对齐

ios - Google+ 集成 iOS - 注销时出现 EXC_BAD_ACCESS 错误

android - 不同 Activity android中的相同GooglePlus客户端对象

java - 泛型上的通配符错误

android - Robolectric:ShadowApplication?

firebase - Flutter: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)