[英]unable to query the files “shared with me” from google drive using Google drive api android
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());
}
};
}
I am not able to query the files and folders that already shared with me by using the above code. 我无法使用上面的代码查询与我共享的文件和文件夹。 Whenever i am trying to query sharedWithMe() i am getting the mResultAdapter array count '0'. 每当我尝试查询sharedWithMe()时,我都会得到mResultAdapter数组计数为'0'。 please help me to solve this issue. 请帮助我解决此问题。
The Android API uses Drive.File scope, which means your app has access to files that have been created by, or explicitly opened with your app. Android API使用Drive.File范围,这意味着您的应用程序有权访问由您的应用程序创建或通过应用程序明确打开的文件。 Other files will not show up in search results. 其他文件将不会显示在搜索结果中。
Cheryl is right, you have to use Google APIs Java Client as said also here: Cheryl是对的,您还必须按照以下说明使用Google API Java Client :
Note: The Google Drive Android API currently only supports drive.file and drive.appfolder authorization scopes. 注意:Google Drive Android API当前仅支持drive.file和drive.appfolder授权范围。 If your application requires additional permissions or features not yet available in the Drive Android API, you must use the Google APIs Java Client. 如果您的应用程序需要其他权限或云端硬盘Android API中尚不可用的功能,则必须使用Google API Java Client。
source: https://developers.google.com/drive/android/auth#connecting_and_authorizing_the_google_drive_android_api 来源: https : //developers.google.com/drive/android/auth#connecting_and_authorizing_the_google_drive_android_api
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.