如何获取Google Drive文件ID [英] How to get Google Drive file ID
问题描述
我使用Google Drive Android API创建了一个文件来驱动root。如何使用Google Client Library共享此文件ID?
I've created a file to Drive root using Google Drive Android API. How can I get this file ID to share it using Google Client Library?
在中获取DriveFileResult> ResultCallback< DriveFileResult>
回调返回null:
String fileId = result.getDriveFile().getDriveId().getResourceId();
推荐答案
回调函数是在本地创建的文件。当文件同步到服务器时,DriveId将只有一个resourceId。在此之前,getResourceId将返回null。
The callback is to the file being created locally. The DriveId will only have a resourceId when the file is synced to the server. Until then getResourceId will return null.
https://developer.android.com/reference/com/google/android/gms/drive/DriveId.html#getResourceId()
使用 CompletionEvents 在与其同步时收到通知服务器发生了。然后调用getResourceId()应该提供你期望的。
Use CompletionEvents to be notified when syncing with the server has occurred. Then calling getResourceId() should deliver what you are expecting.
这篇关于如何获取Google Drive文件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!