2013-10-04 96 views
3

我想實現谷歌加登錄的Android應用程序。我遵循了谷歌開發者頁面「https://developers.google.com/+/mobile/android/getting-started」的指南。我唯一的問題是,當設備上只有一個Google帳戶時,帳戶選擇器對話框不顯示。有沒有解決的辦法?谷歌登錄不顯示具有單個谷歌帳戶設備的帳戶選擇器

Google Plus Account Picker

+3

如果您明確使用'AccountPicker'(而不是Google+的「快速入門」教程的一部分),則會有一個'alwaysPromptForAccount'參數來改變這種行爲。不過,請注意@ tyczj的評論。更改默認行爲將爲您的用戶帶來不必要的工作。 – acj

+0

@tyczj,我希望用戶能夠選擇添加一個不同的帳戶。 – euniceadu

+0

@euniceadu如果有一個帳戶,他們將如何選擇另一個帳戶? – tyczj

回答

5

我使用的AccountPicker通過@acj的建議。我開始一個AccountPicker意圖

Intent intent = AccountPicker.newChooseAccountIntent(null, null, 
       new String[] { "com.google" }, true, null, null, null, 
       null); 
     startActivityForResult(intent, ACCOUNT_PICKER_REQUEST_CODE); 

並返回結果的時候,我初始化GoogleApiClient,設置帳戶名開發者頁面上說:

GoogleApiClient client = new GoogleApiClient.Builder(this) 
    .addApi(Plus.API) 
    .addScope(Plus.SCOPE_PLUS_LOGIN) 
    .setAccountName("[email protected]") 
    .build(); 
client.connect(); 

@dcool,希望這有助於。

+0

謝謝你會試試看。 – dcool

+0

@dcool,它是否適合你? – euniceadu

相關問題