对于具有单个Google帐户的设备,Google登录名不显示帐户选择器 [英] Google login does not show account picker for devices with single google accounts
问题描述
我正在尝试为Android应用实现google plus登录.我遵循了Google开发人员页面上的指南" https://developers.google. com/+/mobile/android/getting-started ".我唯一的问题是,当设备上只有一个Google帐户时,不会显示帐户选择器"对话框.有办法解决吗?
I'm trying to implement google plus sign in for an android app. I followed the guide on the google developer page "https://developers.google.com/+/mobile/android/getting-started". My only problem is that when there's only one google account on the device, the account picker dialog does not show. Is there a way around this?
推荐答案
我使用了@acj建议的AccountPicker.我启动一个AccountPicker意图
I used an AccountPicker as suggested by @acj. I start an 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:
and when the result is returned, I initialize the GoogleApiClient, setting the accountName as stated on the developer page:
GoogleApiClient client = new GoogleApiClient.Builder(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.setAccountName("users.account.name@gmail.com")
.build();
client.connect();
@dcool,希望这会有所帮助.
@dcool, hope this helps.
这篇关于对于具有单个Google帐户的设备,Google登录名不显示帐户选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!