我正在尝试为 Android 应用程序实现 google plus 登录。我按照谷歌开发者页面上的指南进行操作“https://developers.google.com/+/mobile/android/getting-started https://developers.google.com/+/mobile/android/getting-started“。我唯一的问题是,当设备上只有一个谷歌帐户时,帐户选择器对话框不会显示。有没有办法解决这个问题?
我按照 @acj 的建议使用了 AccountPicker。我启动一个 AccountPicker 意图
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("[email protected] /cdn-cgi/l/email-protection")
.build();
client.connect();
@dcool,希望这有帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)