我正在尝试从我的Google驱动器中捕获某些公共文件的下载链接,但方法metadataBuffer.getCount()
始终返回0。
我在其他帖子中看到问题是范围
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(context);
builder.addApi(Drive.API);
builder.addScope(Drive.SCOPE_FILE);
builder.setAccountName(EXTRA_ACCOUNT_NAME);
builder.addConnectionCallbacks(connectionCallbacks);
builder.addOnConnectionFailedListener(connectionFailedListener);
googleApiClient = builder.build();
googleApiClient.connect(); // always connection success
但是只有两个选项“范围”显然是Drive.SCOPE_FILE
和Drive.SCOPE_FOLDER
。
private ResultCallback<DriveApi.MetadataBufferResult> metadataBufferCallback = new ResultCallback<DriveApi.MetadataBufferResult>() {
@Override
public void onResult(@NonNull DriveApi.MetadataBufferResult metadataBufferResult) {
MetadataBuffer metadataBuffer = metadataBufferResult.getMetadataBuffer();
int count = metadataBuffer.getCount(); // <--- always return 0
Log.d(TAG, "count " + count);
}
};
如何使用Drive API v3查看公用文件夹中的所有文件?