Google登录信息不会显示具有单个Google帐户的设备的帐户选择器

时间:2013-10-04 15:06:54

标签: android google-plus google-login

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

Google Plus Account Picker

1 个答案:

答案 0 :(得分:5)

我使用了@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("users.account.name@gmail.com")
     .build();
client.connect();

@dcool,希望这有帮助。