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

eun*_*adu 3 android google-login google-plus

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

Google Plus帐户选择器

eun*_*adu 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);
Run Code Online (Sandbox Code Playgroud)

当结果返回时,我初始化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();
Run Code Online (Sandbox Code Playgroud)

@dcool,希望这会有所帮助.