简体   繁体   English

Google Drive Android Api和Drive同步时间

[英]Google Drive Android Api and Drive sync time

I am introducing in Google Drive Android Api as docs and examples show. 我将在Google Drive Android Api中进行介绍,如文档示例所示。
I created two activities which extend BaseDemoActivity of the example: the first one adds empty files to Drive customizing on each file some CustomProperties, the second one lists from Drive the files added grabbing the owned CustomProperties of each file. 我创建了两个活动,以扩展示例的BaseDemoActivity :第一个活动将空文件添加到Drive中,在每个文件上自定义一些CustomProperty,第二个活动从Drive中列出添加的文件,并抓住每个文件的拥有的CustomProperty。

first activity - code which adds files like this: 第一次活动-添加如下文件的代码:

DriveFolder folder = Drive.DriveApi.getFolder(getGoogleApiClient(),
        mFolderDriveId);

CustomPropertyKey customPropertyKeyExample = new CustomPropertyKey(
        "custom", CustomPropertyKey.PRIVATE);

MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
        .setTitle("New empty file")
        .setMimeType("text/plain")
        .setCustomProperty(customPropertyKeyExample, "xyz")
        .build();

folder.createFile(getGoogleApiClient(), changeSet, null)
        .setResultCallback(fileCallback);

second activity - code which reads properties like this: 第二个活动-读取如下属性的代码:

for (Iterator<Metadata> i = result.getMetadataBuffer().iterator(); i
        .hasNext();) {
        Metadata mChildren = ((Metadata) i.next());
        if (!mChildren.isTrashed()) {
            Map<CustomPropertyKey, String> mapProperties = mChildren
                .getCustomProperties();
            if (mapProperties.get(customPropertyKeyExample) == null) 
                // THIS TEST RETURNS TRUE UNTIL DRIVE SYNC EXECUTES
            }
        }
}

Them work, but i notice that the second activity, the list activity, must wait a Drive variable sync time to have the CustomProperties available. 他们工作,但我注意到第二个活动,即列表活动,必须等待Drive变量同步时间才能使用CustomProperty。

Is there a way to get the CustomProperties from an activity immediately after them added by a different activity? 在其他活动添加CustomProperty后,是否可以立即从活动中获取CustomProperty?

This isn't expected behavior. 这不是预期的行为。 Custom file properties should be available locally without performing a sync. 自定义文件属性应在本地可用而不执行同步。

I've created a bug on our issue tracker to discuss this further: https://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3848 我在问题跟踪器上创建了一个错误,以进一步讨论此问题: https : //code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3848

Could you please respond on the bug, answering the following question: 您能否回答该错误,请回答以下问题:

  1. Can you verify that the title is also changed immediately? 您可以验证标题是否也立即更改了吗?
  2. Which example class specifically are you using for your first and second activity? 您在第一个和第二个活动中具体使用哪个示例类?
  3. How are you sharing the DriveId for the folder between the activities? 您如何在活动之间共享文件夹的DriveId?
  4. Are you using DriveFolder#listChildren or another query to get [result] in the second example? 您是否在第二个示例中使用DriveFolder#listChildren或其他查询来获取[结果]?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM