gpt4 book ai didi

android - 查询失败 Google Drive Android

转载 作者:行者123 更新时间:2023-11-30 00:20:35 27 4
gpt4 key购买 nike

我正在使用这段代码:

GoogleApiClient client = new GoogleApiClient.Builder(this).addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addScope(Drive.SCOPE_APPFOLDER)
.build();
Query query = new Query.Builder().addFilter(Filters.and(Filters.and(Filters.and(Filters.eq
(SearchableField.TITLE, getString(R.string.app_name)), Filters
.eq(SearchableField.TRASHED, false)), Filters.eq(SearchableField.PARENTS, Collections
.singletonList(Drive.DriveApi
.getRootFolder(client)
.getDriveId()))), Filters.eq(SearchableField.MIME_TYPE, GoogleDriveClient.FOLDER_MIME))).build();
DriveApi.MetadataBufferResult result = Drive.DriveApi.query(client, query).await(TIMEOUT, TimeUnit.SECONDS);
if (!result.getStatus().isSuccess()) {
client.disconnect();
return;
}

总是报错:Status{statusCode=INTERNAL_ERROR, resolution=null}

我在 Google 控制台中启用了 Drive Api,我再次检查了我的 SHA1 指纹并且其他操作正常。是否允许执行查询?

最佳答案

这是 Querying for Files 的文档

You can use the com.google.android.gms.drive.query package to search a user's Drive account for files whose metadata match your search criteria. You can issue a query for a specific folder or on the entire filesystem.

Note: The Android Drive API only works with the https://www.googleapis.com/auth/drive.file scope. This means that only files which a user has opened or created with your application can be matched by a query.

这是构建查询的示例。

A query is created by building an instance of the Query class and specifying the search criteria with Filters. The following example finds all files with the title "HelloWorld.java".

Query query = new Query.Builder()
.addFilter(Filters.eq(SearchableField.TITLE, "HelloWorld.java"))
.build();

You can use the Filters class to build expressions. Multiple filters can be joined together using the and and or methods.

Once a Query object has been constructed it can be executed on the entire file system using Drive.DriveApi as follows:

Drive.DriveApi.query(googleApiClient, query);

This query starts in the My Drive (the root) folder and recursively traverse the entire filesystem, returning all entries matching the Filters expression tree.

A query can alternatively be executed only in a specific folder using an instance of the DriveFolder class, as shown by:

DriveFolder folder= ...;
folder.query(query);

This call does not scan recursively; only direct entries in this folder matching filter conditions are returned.

关于android - 查询失败 Google Drive Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46379477/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com