code: void logout() {
          try {
              Auth.GoogleSignInApi.signOut(client).setResultCallback(new ResultCallback<Status>() {
                  @Override
                  public void onResult(@NonNull Status status) {
                      if (!status.isSuccess()) {
                          Log.w(TAG, "Couldn't clear account and credentials");
                      }
                  }
              });
          } catch (IllegalStateException e) {
              Log.e(TAG, "Failed to clear the Google Plus Session", e);
          }
      }
docs: Logs out the current signed in account.