簡體   English   中英

使用Google API從Android應用程序取消驅動器帳戶的鏈接

[英]Unlink drive account from android app using google api

我已經能夠使用以下方式在我的應用中授權一個Google帳戶

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);

這將打開一個對話框,要求用戶選擇他們要授權的帳戶。

我想允許用戶斷開連接或更改關聯的帳戶。

我想Google Play庫會將信息存儲在我的應用程序中,因為當我刪除應用程序數據時,我可以要求用戶再次連接。

因此,我想知道如何從我的應用程序取消鏈接Google帳戶。

嘿,您應該使用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帳戶取消鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM