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

前端 未结 5 1828
深忆病人
深忆病人 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:45

    Just call

    mGoogleApiClient.clearDefaultAccountAndReconnect();

    have a look at the docs.

    This will call the onConnectionFailed callback that will present the layout to choose among the available Google accounts:

    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) 
    {
        if (connectionResult.hasResolution()) {
            try {                                              
                connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
            } catch (IntentSender.SendIntentException e) {
                // Unable to resolve, message user appropriately
            }
        } else {                                           
            GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show();
        }
    
    }
    

提交回复
热议问题