Google Drive Android API - Invalid DriveId and Null ResourceId

前端 未结 1 1249
渐次进展
渐次进展 2020-12-11 23:09

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

The problem is that the folder gets created successfu

相关标签:
1条回答
  • 2020-12-11 23:39

    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

    0 讨论(0)
提交回复
热议问题