Google Drive Android API - Invalid DriveId and Null ResourceId

依然范特西╮ 提交于 2019-11-28 14:02:35
seanpj

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)'.

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.

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).

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

There is a related problem discussed in SO 34318220.

Good Luck

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!