Esempio n. 1
0
 @Override
 public void onClick(View v) {
   if (!mGoogleApiClient.isConnecting()) {
     // We only process button clicks when GoogleApiClient is not
     // transitioning between connected and not connected.
     switch (v.getId()) {
       case R.id.sign_in_button:
         mStatus.setText(R.string.status_signing_in);
         resolveSignInError();
         break;
       case R.id.sign_out_button:
         // We clear the default account on sign out so that Google
         // Play services will not return an onConnected callback
         // without user interaction.
         Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
         mGoogleApiClient.disconnect();
         mGoogleApiClient.connect();
         break;
       case R.id.revoke_access_button:
         // After we revoke permissions for the user with a
         // GoogleApiClient instance, we must discard it and create a
         // new one.
         Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
         // Our sample has caches no user data from Google+, however
         // we would normally register a callback on
         // revokeAccessAndDisconnect to delete user data so that we
         // comply with Google developer policies.
         Plus.AccountApi.revokeAccessAndDisconnect(mGoogleApiClient);
         mGoogleApiClient = buildGoogleApiClient();
         mGoogleApiClient.connect();
         break;
     }
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LoginActivity.mGoogleApiClient.registerConnectionCallbacks(this);

    Plus.AccountApi.revokeAccessAndDisconnect(LoginActivity.mGoogleApiClient);
  }
Esempio n. 3
0
  // [START on_disconnect_clicked]
  private void onDisconnectClicked() {
    // Revoke all granted permissions and clear the default account.  The user will have
    // to pass the consent screen to sign in again.
    if (mGoogleApiClient.isConnected()) {
      Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
      Plus.AccountApi.revokeAccessAndDisconnect(mGoogleApiClient);
      mGoogleApiClient.disconnect();
    }

    showSignedOutUI();
  }
Esempio n. 4
0
 public void revokeGplusAccess() {
   if (mGoogleApiClient.isConnected()) {
     Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
     Plus.AccountApi.revokeAccessAndDisconnect(mGoogleApiClient)
         .setResultCallback(
             new ResultCallback<Status>() {
               @Override
               public void onResult(Status arg0) {
                 Log.e(TAG, "User access revoked!");
                 mGoogleApiClient.connect();
                 updateUI(false);
               }
             });
   }
 }
 private void disconnect() {
   try {
     Plus.AccountApi.revokeAccessAndDisconnect(mGoogleApiClient)
         .setResultCallback(
             new ResultCallback<Status>() {
               @Override
               public void onResult(Status status) {
                 // mGoogleApiClient is now disconnected and access has been revoked.
                 // Don't care if it was disconnected already (status != success).
                 buildGoogleApiClient();
                 savedCallbackContext.success("disconnected");
               }
             });
   } catch (IllegalStateException e) {
     savedCallbackContext.success("disconnected");
   }
 }