简体   繁体   English

谷歌驱动器配额使用android api驱动器

[英]google drive quota using android api for drive

How can I get the amount of storage and used quota of a user's google drive account? 如何获得用户的Google云端硬盘帐户的存储空间和已用配额? I'm building an android app with the android api for drive: https://developers.google.com/drive/android/ . 我正在使用用于驱动器的android api构建一个android应用程序: https : //developers.google.com/drive/android/

I couldn't find any method that could return the details for me, but, I believe I have to use call the rest api like shown here: https://developers.google.com/drive/v2/reference/about/get . 我找不到任何可以为我返回详细信息的方法,但是,我相信我必须使用如下所示的调用rest api: https : //developers.google.com/drive/v2/reference/about/get How do I retrieve the drive service instance? 如何检索驱动器服务实例? I already have mGoogleAuthClient which can talk to drive APIs. 我已经有了可以与驱动器API进行通信的mGoogleAuthClient。 Any help? 有什么帮助吗?

Something like this: 像这样:

com.google.android.gms.common.api.GoogleApiClient mGAC = new GoogleApiClient
  .Builder(this)
  .addApi(com.google.android.gms.drive.Drive.API)
  .addScope(com.google.android.gms.drive.Drive.SCOPE_FILE)
  .addConnectionCallbacks(this)
  .addOnConnectionFailedListener(this)
  .setAccountName(email)
  .build(); 

com.google.api.services.drive.Drive mGSvc = new Drive
  .Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(),
  GoogleAccountCredential
    .usingOAuth2(this, Collections.singletonList(DriveScopes.DRIVE_FILE))
    .setSelectedAccountName(email)
  ).build();
  }

gives you access to both the GDAA and the REST Apis. 使您可以访问GDAAREST Apis。

But remember a few things: 但是请记住以下几点:

That means that mixing the two involves some timing consideration . 这意味着将两者混合需要一些时序考虑

Good Luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM