Google login does not show account picker for devices with single google accounts

痞子三分冷 提交于 2019-12-22 10:44:10

问题


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?


回答1:


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);

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, hope this helps.



来源:https://stackoverflow.com/questions/19184652/google-login-does-not-show-account-picker-for-devices-with-single-google-account

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!