我在Google Drive Android Api中引入了docs和examples 我创建了两个扩展示例的 BaseDemoActivity 的活动:第一个将空文件添加到Drive上,在每个文件上自定义一些CustomProperties,第二个从Drive中列出添加的文件,抓取每个文件的拥有的CustomProperties。
第一个活动 - 添加如下文件的代码:
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);
第二个活动 - 读取此类属性的代码:
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
}
}
}
他们工作,但我注意到第二个活动,列表活动,必须等待Drive变量同步时间才能使CustomProperties可用。
是否可以通过其他活动添加活动后立即从活动中获取CustomProperties?
答案 0 :(得分:1)
这不是预期的行为。自定义文件属性应在本地可用,而不执行同步。
我在问题跟踪器上创建了一个错误,以便进一步讨论: https://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3848
请你回答一下这个问题,回答以下问题: