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