How do I switch accounts under the NEW Google Drive Android API

前端 未结 5 1827
深忆病人
深忆病人 2020-12-03 05:48

My authorization flow in the new Google Drive Android API is as follows:

  1. Menu: SELECT ACCOUNT
  2. connect();
  3. onConnectionFailed() result.startRe
5条回答
  •  半阙折子戏
    2020-12-03 06:25

    First, add the Plus.API:

    mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Drive.API).addApi(Plus.API).addScope(Drive.SCOPE_APPFOLDER).addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();
    

    Then you can switch accounts like this:

    public void onClick(View view) {
      if (view.getId() == R.id.sign_out_button) {
        if (mGoogleApiClient.isConnected()) {
          Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
          mGoogleApiClient.disconnect();
          mGoogleApiClient.connect();
        }
      }
    }
    

    For more, see here.

提交回复
热议问题