使用google api从Android应用取消链接驱动器帐户

时间:2014-10-15 15:14:23

标签: android google-play-services google-api-client

我已经能够使用

在我的应用中授权谷歌帐户
mGoogleApiClient = new GoogleApiClient.Builder(this)
      .addApi(Drive.API)
      .addScope(Drive.SCOPE_FILE)
      .addConnectionCallbacks(this)
      .addOnConnectionFailedListener(this)
      .build();
mGoogleApiClient.connect();

然后

connectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLUTION);

打开一个对话框,要求用户选择要授权的帐户。

我想允许用户断开连接或更改关联帐户。

我想谷歌播放库会在我的应用程序中存储信息,因为当我删除应用程序数据时,我可以要求用户再次连接。

所以我想知道如何取消谷歌帐户与我的应用程序的链接。

1 个答案:

答案 0 :(得分:0)

嘿,你应该用Plus API创建你的Api客户端;

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

然后你就可以退出;

Plus.AccountApi.clearDefaultAccount(mApi);
mApi.disconnect();

您的应用应该与googledrive帐户成功取消关联。