无法检索上传到 google 驱动器应用程序文件夹的文件的驱动器 ID

Unable to retrieve drive id for file uploaded to google drive app folder

我正在尝试从 google drive app 文件夹下载一个文件,为此我需要驱动器 ID(我想是这样)但是有了驱动器 ID,我使用下面的代码,我不断得到file/folder 未发现错误。

Drive.DriveApi.getAppFolder(mGoogleApiClientDrive)
            .listChildren(mGoogleApiClientDrive)
            .setResultCallback(new ResultCallback<DriveApi.MetadataBufferResult>() {
                @Override
                public void onResult(DriveApi.MetadataBufferResult result) {
                    if (!result.getStatus().isSuccess()) {
                        Toast.makeText(GoogleSignIn.this, "Unable to get any result", Toast.LENGTH_SHORT).show();
                    }

                    MetadataBuffer mdb = result.getMetadataBuffer();
                    String ID = mdb.get(0).getDriveId().encodeToString();

                    // Method for downloading data from google drive
                    downloadContent(ID);
                }
            });

当然是我在尝试获取驱动器 ID 时做错了什么。也尝试了 getResourceID() 的运气,但又出现了同样的错误。

您是否仔细检查了您的 SCOPE?代码应如下所示:

GoogleApiClient mGAC = new GoogleApiClient.Builder(act)
  .addApi(Drive.API)
  .addScope(Drive.SCOPE_FILE)
  .addScope(Drive.SCOPE_APPFOLDER)
  .addConnectionCallbacks( ...  )
  .addOnConnectionFailedListener( ...)
  .setAccountName(email)
  .build();

祝你好运