gpt4 book ai didi

android - 无法使用 Google drive api android 从 google drive 查询文件 "shared with me"

转载 作者:行者123 更新时间:2023-11-29 20:58:09 25 4
gpt4 key购买 nike

public class QueryFilesSharedWithMeActivity extends BaseDemoActivity {

private ListView mResultsListView;
private ResultsAdapter mResultsAdapter;

@Override
protected void onCreate(Bundle b) {
super.onCreate(b);
setContentView(R.layout.activity_listfiles);
mResultsListView = (ListView) findViewById(R.id.listViewResults);
mResultsAdapter = new ResultsAdapter(this);
mResultsListView.setAdapter(mResultsAdapter);
}

/**
* Clears the result buffer to avoid memory leaks as soon as the activity is no longer
* visible by the user.
*/
@Override
protected void onStop() {
super.onStop();
mResultsAdapter.clear();
}

@Override
public void onConnected(Bundle connectionHint) {
super.onConnected(connectionHint);
Query query = new Query.Builder()
.addFilter(Filters.sharedWithMe())
.build();
Drive.DriveApi.query(getGoogleApiClient(), query)
.setResultCallback(metadataCallback);
showMessage("Connecting ...");
}

final private ResultCallback<DriveApi.MetadataBufferResult> metadataCallback =
new ResultCallback<DriveApi.MetadataBufferResult>() {
@Override
public void onResult(DriveApi.MetadataBufferResult result) {
showMessage("onResult ...");
if (!result.getStatus().isSuccess()) {
showMessage("Problem while retrieving results");
return;
}
mResultsAdapter.clear();
mResultsAdapter.append(result.getMetadataBuffer());
showMessage("Count = "+mResultsAdapter.getCount());
}
};
}

我无法使用上述代码查询已与我共享的文件和文件夹。每当我尝试查询 sharedWithMe() 时,我都会得到 mResultAdapter 数组计数“0”。请帮我解决这个问题。

最佳答案

Android API 使用 Drive.File 范围,这意味着您的应用可以访问由您的应用创建或明确打开的文件。其他文件不会出现在搜索结果中。

关于android - 无法使用 Google drive api android 从 google drive 查询文件 "shared with me",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26992251/

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