2017-06-15 78 views
1

無法多個賬戶之間,同時登錄通過谷歌谷歌加帳戶登錄/註銷不能正常工作

我使用谷歌加選擇(第二次及以上)登錄自己的Android應用程序。每件事情都很好。但是,當我第一次嘗試登錄(應用程序安裝後)是否給我選擇不同的谷歌帳戶(如果我有更多的1帳戶登錄到我的設備) enter image description here,但是當我註銷並再次登錄它不給我這個選擇選項,它會自動使用先前選擇的帳戶登錄。

我使用此代碼進行註銷。

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).build(); 
      GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(context) 
        .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 
        .build(); 
      Auth.GoogleSignInApi.signOut(mGoogleApiClient); 
      Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient); 

我還通過signOut文件走了,我的理解,從有「刪除在谷歌播放服務,爲您的應用程序設置的默認賬戶」,但它不工作。有沒有解決方案來做到這一點?

請人幫忙找解決方案

+0

嘗試全光照此: - Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); –

+0

@Sachin Rao這是棄用的方法singOut()將完成其工作,請參閱我提到的鏈接。 –

+0

好的。你有沒有檢查過這個:https://developers.google.com/identity/sign-in/android/disconnect –

回答

1

它的工作對我來說,可能會幫助妳。

雖然連接用:

if (mGoogleApiClient == null) { 

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) 
                  .requestEmail() 
                  .requestProfile() 
                  .build(); 

       mGoogleApiClient = new GoogleApiClient.Builder(getContext()) 
               .enableAutoManage(getActivity(), new GoogleApiClient.OnConnectionFailedListener() { 
       @Override 
       public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { 

                 Log.e("Error Google Conn", "" + connectionResult.toString()); 
                } 
               }) 
               .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 
               .addApi(Plus.API) 
               .addApi(AppIndex.API).build(); 

        mGoogleApiClient.connect(); 
       } 

雖然斷開:

if (mGoogleApiClient.isConnected()) 
{    
    Auth.GoogleSignInApi.signOut(mGoogleApiClient); 
    Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); 
      mGoogleApiClient.disconnect(); 
} 
+0

沒有看到我們的代碼有太大的區別,但我將嘗試更新 –

+0

它沒有工作。 –