Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

Google Plus Account Picker

like image 372
euniceadu Avatar asked Sep 02 '25 09:09

euniceadu


1 Answers

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("[email protected]")
     .build();
client.connect();

@dcool, hope this helps.

like image 97
euniceadu Avatar answered Sep 05 '25 02:09

euniceadu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!