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.