2016-12-17 6 views
0

Googleのサインインを最初にクリックすると、それ以上が選択されているかどうか尋ねられます。二度目は、以前に選択された\ cを使って原子的にログインしています。私は常に\ cはGoogleはいつでも選択するアカウントを尋ねる

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

       } 
      }) 
      .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 
      .build(); 

私は疲れmGoogleApiClient.clearDefaultAccountAndReconnectを()選択表示することができますどのように

。 しかしそのOnActivityResult

GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); 
      handleSignInResult(result); 

Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient); 
        startActivityForResult(signInIntent, 100); 

をクリックしてください今、あなたは機能handleSignInResult(result)を作成し、提供情報を使用し、ボタンでの符号に

答えて

1
You will have to use the revoke access callback. 

googleApiClient = new GoogleApiClient.Builder(this) 
        .enableAutoManage(LoginActivity.this , this) 
        .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 
        .addApi(AppIndex.API).build(); 

を接続していないクライアントとして私のクラッシュ与えられましたコールバックでアクセスが取り消されるためです。 ここで情報を得て、あなたがしたいことをします。

あなたgoogleApiCLient

googleApiClient.registerConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() { 
      @Override 
      public void onConnected(@Nullable Bundle bundle) { 
       if (googleApiClient.isConnected()) { 
        Auth.GoogleSignInApi.revokeAccess(googleApiClient).setResultCallback(
          new ResultCallback<Status>() { 
           @Override 
           public void onResult(@NonNull Status status) { 
            Log.e("getOut",status.toString()); 
           } 
          }); 
       } 
      } 
      @Override 
      public void onConnectionSuspended(int i) { 

      } 
     }); 

にこのコールバックを追加します。このコールバックは、すべてのアカウントからのアクセスを無効になり、Gmailアカウントを毎回選択するダイアログが表示されます。

希望すると、これが役立ちます。

+1

onConnectedが呼び出されていない – andro

+1

signOutでローカルデバイスには十分である必要があります。取り消しを行うとデバイス間でこの問題が発生します... https://developers.google.com/identity/sign-in/android/disconnect –

関連する問題