Android SDK中的Google云端硬盘文件夹列表问题

时间:2016-04-26 16:03:15

标签: android google-drive-api

在Google云端硬盘中,我遇到了这个问题:

  

状态{statusCode =找不到驱动器项,或者您无权访问它。,resolution = null}

用于从Google云端硬盘文件夹中获取文件列表。

我正在使用Google Drive Android SDK。你能帮我解决这个问题吗?

以下是我要遵循的源代码:

    Drive.DriveApi.fetchDriveId(mGoogleApiClient, "DriveId:CAESABiErgEg3t2Dj4VVKAE=").setResultCallback(new ResultCallback<DriveApi.DriveIdResult>() {
            @Override
            public void onResult(DriveApi.DriveIdResult result) {

                Log.d(TAG, "Result: " + result.getStatus().toString());
                if (!result.getStatus().isSuccess()) {
                    Log.d(TAG, "Cannot find DriveId. Are you authorized to view this file?");
//                    showMessage("Cannot find DriveId. Are you authorized to view this file?");
                    return;
                }
                DriveId driveId = result.getDriveId();
                DriveFolder folder = driveId.asDriveFolder();
                Query query = new Query.Builder()
                        .addFilter(Filters.eq(SearchableField.MIME_TYPE, "audio/*"))
                        .build();
                folder.queryChildren(mGoogleApiClient, query)
                        .setResultCallback(new ResultCallback<DriveApi.MetadataBufferResult>() {
                            @Override
                            public void onResult(DriveApi.MetadataBufferResult result) {
                                if (!result.getStatus().isSuccess()) {
                                    Log.d(TAG, "Problem while retrieving files");
//                                    showMessage("Problem while retrieving files");
                                    return;
                                }

                                Log.d(TAG, "result.getMetadataBuffer(): " + result.getMetadataBuffer());
                                /*mResultsAdapter.clear();
                                mResultsAdapter.append(result.getMetadataBuffer());
                                showMessage("Successfully listed files.");*/
                            }
                        });
            }
        });

0 个答案:

没有答案