哪儿来的" createFromResourceId()"走? [英] Where did the "createFromResourceId()" go?

查看:161
本文介绍了哪儿来的" createFromResourceId()"走?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经更新到谷歌的新版本播放服务4.2(库版本15)。突然间,来电来DriveId.createFromResourceId(......)是没有得到解决。

I have updated to the new version of Google Play Services 4.2 (library version 15). And suddenly, the calls to DriveId.createFromResourceId("....") are unresolved.

DriveId sFolderId = DriveId.createFromResourceId("0B2EE......N3J6RU0"); 

我知道我可以使用的 DriveId 连接codeToString()/德codeFromString()代替,但:

  1. RESOURCEID直接对应与谷歌驱动器文件的HTTP。
  2. 即使文件被操纵看来是持续

无论是文档和的演示code 使用方法广泛。另外,镜子的方法 getResourceId()仍然存在。
多的问题,这是澄清要求从谷歌驱动器 / 谷歌播放的SVC 乡亲。

Both the documentation and demo code uses the method extensively. Also, the mirror method getResourceId() is still in existence.
More than a question, it is a request for clarification from the Google Drive / Google Play Svcs folks.

推荐答案

我测试Burcu的答案,可惜没有奏效。或者,也许我措辞不当的问题。我会尝试重新短语它(我找到了正确的答案)。

I tested Burcu's answer, and unfortunately it did not work. Or maybe I phrased the question incorrectly. I'll try to re-phrase it (and I found the correct answer).

有两种不同的字符串类型的ID重新$ P $可供DriveId(包括文件和文件夹)。

There are 2 different string type ID representations available for DriveId (both file and folder).

1/ DriveId.encodeToString(), resulting in something like:
"DriveId:CAESHDBCMW1RVVcyYUZKZmRhakIzMDBVbXMYjAUgssy8yYFRTTNKRU55"
2/ and DriveId.getResourceId(), resulting in shorter:
"UW2aFJfdajB3M3JENy00Ums0B1mQ"

在4.1,有2种方法,将将这些回DriveId

In 4.1, there were 2 methods that would turn these back to the DriveId

1/ DriveId.decodeFromString(DriveId.encodeToString());
2/ DriveId.createFromResourceId(DriveId.getResourceId());

他们都在对正常工作,我选择了RESOURCEID品种,因为这短短的字符串出现在其他系统中使用http地址(Google Apps脚本...)。例如: https://docs.google.com/file/d/UW2aFJfdajB3M3JENy00Ums0B1mQ
此外,它似乎是持久的,即使文件被操纵,谷歌驱动器(丢弃,恢复,移动)。

Both of them worked correctly in pairs and I chose the ResourceId variety, since this short string appears in http address used in other systems (Apps Script...). For example: https://docs.google.com/file/d/UW2aFJfdajB3M3JENy00Ums0B1mQ
Also, it appears to be persistent even if the file is manipulated in Google Drive (trashed, restored, moved).

但在4.2,在 createFromResourceId()消失和无法改为德codeFromString()是这样的:

But in 4.2, the createFromResourceId() disappeared and CAN NOT be replaced by "decodeFromString()" like this:

//INCORRECT    
DriveId.decodeFromString(DriveId.getResourceId());

相反,从RESOURCEID的DriveId有要检索这样:

Instead, the DriveId from ResourceId has to be retrieved this way:

DriveIdResult result = Drive.DriveApi.fetchDriveId(GAC, DriveId.getResourceId()).await();
DriveId drvID = result.getDriveId();

(我用的是计谋的版本为简单起见)。

(and I use the "await" version for simplicity).

所以得出的结论是: 所述createFromResourceId()代替

So the conclusion is: The createFromResourceId() was replaced by

Drive.DriveApi.fetchDriveId(GAC, DriveId.getResourceId()).await().getDriveId()

需要提醒的是,伺机()结构的实施,应该在正常的UI线程回调。

with the caveat that the "await()" construct should be implemented as a callback in normal UI thread.

更新(2014年10月23号)

以上答案很陈旧,请参考下面的评论。

The answer above is quite stale, please refer to the comments below.

这篇关于哪儿来的" createFromResourceId()"走?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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