谷歌推动Android API - 无效DriveId和空RESOURCEID [英] Google Drive Android API - Invalid DriveId and Null ResourceId

查看:138
本文介绍了谷歌推动Android API - 无效DriveId和空RESOURCEID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在争夺C时不幸运了整整一天这个$ C $。我开始按照此code <一个href="https://github.com/googledrive/android-demos/blob/master/app/src/main/java/com/google/android/gms/drive/sample/demo/BaseDemoActivity.java"相对=nofollow>从谷歌样本。

I have been battling this code the whole day without luck. I started by following this code sample from Google.

现在的问题是,该文件夹被成功但内部创建的 onResult(),我总是得到DriveId或RESOURCEID无效或不完整的。这意味着我不能创建我创建的文件夹中的文件。这里是code我使用的:

The problem is that the folder gets created successfully but inside onResult(), I always get a DriveId or resourceId that is invalid or incomplete. That means I cannot create a file inside the folder I created. Here is the code I am using:

public class CreateFolderActivity extends BaseDemoActivity {

@Override
public void onConnected(Bundle connectionHint) {
    super.onConnected(connectionHint);
    MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
            .setTitle("MyAppFolder").build();
    Drive.DriveApi.getRootFolder(getGoogleApiClient()).createFolder(
            getGoogleApiClient(), changeSet).setResultCallback(callback);
}

final ResultCallback<DriveFolderResult> callback = new ResultCallback<DriveFolderResult>() {
    @Override
    public void onResult(DriveFolderResult result) {
        if (!result.getStatus().isSuccess()) {
            showMessage("Error while trying to create the folder");
            return;
        }

        // this value is always invalid with ending == operators
        Log.d("DRIVEID", "Created a folder: " + result.getDriveFolder().getDriveId());
    }
  };
}

每当我运行此code,我得到了以下的ID,它不完整的出现:

Whenever I run this code, I get the following id which appears incomplete:

CAESABi2VyCCzdWOuVMoAQ==

我不知道这里发生了什么!

I don't know what is happening here!

我已经Google'd各地和阅读增加监听​​器监听完成事件,但他们都不上班了。

I have Google'd around and read of adding listeners to listen for completion events but none of them seem to work.

我看到的这近类似的问题在左右,但他们没有为我工作。

I have seen nearly similar questions on SO on this but none of them work for me.

我手动复制FolderId通过我的浏览器后,创建的应用程序,然后粘贴到我的Andr​​oid code和应用程序成功地创建了一个文件。但是,这不是事情应该如何工作。

I manually copied the FolderId through my browser after the app created it and then pasted to my android code and the app created a file successfully. But this is not how things should work.

我是想等到同步完成,如果是这样,如何​​?

Am I suppose to wait for the sync to complete and if so, how?

感谢你在前进!

推荐答案

回答你的问题,也许可以找到<一href="http://stackoverflow.com/questions/22874657/un$p$pdictable-result-of-driveid-getresourceid-in-google-drive-android-api/31553269#31553269">here.你得到的DriveId是确定的,但你不应该直接处理。这是一个的 preliminary 的DriveId,经过修改的对象一直致力于(同样,见<一href="http://stackoverflow.com/questions/22874657/un$p$pdictable-result-of-driveid-getresourceid-in-google-drive-android-api/31553269#31553269">SO 22874657 )。您可以测试它比较DriveId你得到与DriveId你会得到onCompletion(CompletionEvent事件)。

The answer to your problem can probably be found here. The DriveId you're getting is OK, but you should not handle it directly. It is a 'preliminary' DriveId that changes after the object has been committed (again, see SO 22874657). You can test it comparing DriveId you're getting vs. DriveId you'll get in 'onCompletion(CompletionEvent event)'.

这只是GDAA逻辑的副作用之一,从上线/离线导致联合国predictable延迟网络状态屏蔽你。你只需要依靠回调。

This is just one of the side effects of GDAA's logic, shielding you from on-line / off-line network state resulting in unpredictable delays. You just have to rely on callbacks.

不过,我觉得很奇怪,你不能用这个'preliminary'DriveId(如果是文件夹),立即为另一个对象(文件夹/文件)的母公司。我从来没有经历过,马上传递'preliminary'DriveId到另一个GDAA方法。
它是万一RESOURCEID的不同。这一个是次要的GDAA,仅使用,如果你的设备的外面去。目前还不知道到GDAA直到对象被提交(上载)。

But I am surprised that you can't use this 'preliminary' DriveId (in case of a folder) immediately as a parent of another object (folder/file). I have never experienced it, passing the 'preliminary' DriveId immediately to another GDAA method.
It is different in case of the ResourceId. That one is secondary in the GDAA and is used only if you go outside of the device. It is not known to the GDAA until the object is committed (uploaded).

我在用类似的逻辑(创建文件夹/文件树)此演示(见MainActivity.createTree( ) 方法)。欢迎你在里面挖。

I used similar logic (creating folder / file tree) in this demo (see MainActivity.createTree() method). You're welcome to dig in it.

好运

这篇关于谷歌推动Android API - 无效DriveId和空RESOURCEID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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