无法查询文件"与ME&QUOT共享;从使用谷歌云端硬盘API谷歌Android驱动器 [英] unable to query the files "shared with me" from google drive using Google drive api android

查看:147
本文介绍了无法查询文件"与ME&QUOT共享;从使用谷歌云端硬盘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());
           }
        };
 }

我不能够使用上述code来查询已与我共享的文件和文件夹。每当我试图查询sharedWithMe()我收到mResultAdapter阵列数0。请帮我解决这个问题。

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'. please help me to solve this issue.

推荐答案

Android的API使用Drive.File范围,这意味着你的应用程序可以访问已被创建,或显式地使用您的应用打开的文件。其他文件将不会在搜索结果中显示出来。

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. Other files will not show up in search results.

这篇关于无法查询文件&QUOT;与ME&QUOT共享;从使用谷歌云端硬盘API谷歌Android驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆