- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
对于我的应用程序,我需要将列表与 Google 云端硬盘同步。我已经实现了 SignIn 并让我的 Main_Activity 实现了这两个:
com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks,
com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener
尽管我阅读了整个Google Drive API for Android文档,更具体地说是 Store Application Data部分。并查看了 example on GitHub ,我无法让它工作。我个人认为这份文档读起来真的很困惑。甚至不清楚适用于 Android 的 Google Drive API 和 Google Drive REST API 之间的区别是什么,以及我应该在我的场景中使用哪一个。
我还注意到 GitHub 上的示例扩展了一个自定义 Activity ,其中包含其他方法。
谁能一步步解释如何使用 android 驱动器 API?
最佳答案
我很了解你的沮丧。有“Google Drive Android API”(GDAA) 和“Drive REST API”。网络上有一些很好的文档,但找到它并理解它可能是一个挑战,尤其是因为包的名称非常相似。此外,“Drive REST API”至少有两个现存版本,您必须保持版本正确。
关于GDAA,你已经找到了这个documentation , 但你应该仔细看看。我建议你做一个简单的 Activity ,比如 creating a file并从那里开始工作。
我认为您引用的 GitHub 示例中的自定义 Activity 是 BaseDemoActivity
。该类只是提供了一些生命周期方法和一些其他常用例程。
Google Drive Android API (GDAA) 与 Play 服务紧密集成,Google 声称可提供更好的性能。 (见备注 here ):
Note: This quickstart illustrates the use of the Drive REST API in an Android application. However, in the majority of cases production Drive apps will strongly benefit by making use of the Drive API for Android, which is integrated with Google Play Services and offers better performance. Before using the Drive REST API in your Android application, you should carefully review the Drive API for Android and use it in your application if possible. A Drive API for Android Quickstart is available if you want to learn more.
尽管如此,由于对同步频率的严格限制,我在大多数情况下都放弃了 GDAA。 (有关更多详细信息,请参阅本文底部的注释。)
使用 GDAA 时,要牢记的一件关键事情是,即使您的代码可以在 UI 线程上运行,GDAA 也不能,因为它代表您执行的任务可能很长。这意味着一旦您请求 GDAA 从 UI 线程完成某些任务,GDAA 将在后台(而不是在 UI 线程上)完成该工作并通过回调将结果传递给您。
这种结构虽然是必要的,但意味着您的代码将是一系列由 GDAA 调用的方法,并且不一定会展示您可能习惯的清晰的顺序格式。我将其视为软件中的弹球机。
虽然这不是一套循序渐进的说明,但我希望这能帮助您指明正确的方向。
关于同步频率:更具体地说,将按照 DrivePreferencesApi
指定的方式上传到服务器。 .上传通常发生得相当快。但是,下载是有速率限制的。参见 this documentation .
In order to avoid excessive load on the device and the server, sync requests are rate limited. In this case, the operation will fail with DRIVE_RATE_LIMIT_EXCEEDED status, which indicates that a sync already happened quite recently so there is no need for another sync. The operation will succeed when reattempted after a sufficient backoff duration.
我认为“退避持续时间”取决于安装的 Play 服务版本。根据我的经验,这个持续时间从几分钟到 1/2 小时或更长时间不等。这可能已经改变,我试图找到这方面的文档,但没有成功。
如果 GDAA 的下载限制对您不起作用,那么您可能需要考虑 Drive REST。您还可以将 Firebase 视为可能的解决方案。
关于Android - 使用适用于 Android 的 Google Drive API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43981182/
我正在尝试使用 Drive SDK 将文件上传到 Google Drive . 我想知道是否有 API 方法来检查用户的驱动器是否有足够的容量来保存文件。如果是,请指出我应该搜索的位置,如果不是,最好
我想在我正在开发的新 android 应用程序(又名 drive.appdata 范围)中使用特殊应用程序数据文件夹中的文件。 谷歌的你们在与 Google Play Services 4.2 捆绑的
列出Google云端硬盘文件的JavaScript示例使用gapi.client.drive.files.list()。 尝试使用此方法时,出现错误“无法读取未定义的属性'files'”。 该问题和解
我正在尝试使用 Google Cloud REST API 获取特定文件夹大小。 我已经尝试过使用 REST API 的“ about ”方法,但在这种方法中,我获得了整个云存储的已用字节总数和可用空
我只是想了解在 G Suite 上使用 Team Drive 获取团队存储库与仅使用 Google Drive 上的共享文件夹相比的优势。通过搜索不同的来源并进行测试,到目前为止我发现了以下结果。 坦
我正在尝试使用 Google Drive API (v3) 更新文档 在 Google 云端硬盘中。 我已阅读此迁移指南: Google Drive API v3 Migration 并对其进行编码以
我曾尝试将我的 Web 应用程序集成到 Google 云端硬盘用户界面(以打开文件),但没有取得多大成功。我无法使用 OAuth 范围 https://www.googleapis.com/auth/
使用Google Drive API时 我使用 com.google.api.services.drive.Drive.files() 来迭代一些文件。 我注意到所有目录对象都没有权限? 当我使用 F
Google Drive API 和 Google Spreadsheet API (v 3.0) 都支持获取与以下 URL 对应的 [KEY] 的方法: https://docs.google.co
我正在尝试将本地 CSV 文件上传到 Google Drive 并在那里像 Google 电子表格一样显示它。但是,当我转到 Google Drive 并单击指向我的文件的链接时,我只能下载它,而不能
我正在尝试使用 ArrayBuffer 的内容在 Google Drive 上创建一个文件。我正在使用 Javascript 和 Drive API 的第 3 版。 我设法使用 this code s
我可以使用 google drive android api 将文本文件上传到 google drive 中的文件夹。 Sample code 但是我想上传一张图片到谷歌驱动器。这可能吗? 创建文本文
我想知道以下是否可行,因为我似乎无法在网上找到任何具体的方法: 当 Google Takeaway 服务将新的 takeout-xxx.zip 文件上传到我的 Google Drive Takeawa
是否可以对 Google Drive 上的文件执行“追加”操作? 假设我想使用 Google Drive 保存日志条目“as-they-come-in”,是否有某种“仅附加”操作可用? 最佳答案 如果
看着 Google Drive scopes .我明白: https://www.googleapis.com/auth/drive.install - 用于让用户批准安装应用程序的特殊范围 如果我希
我有一个带有两个父文件夹( FILE-1 和 FOLDER-1 )的文档( FOLDER-2 )。 如果我删除 FOLDER-1 , FILE-1也被删除。然而,我预计只有FOLDER-1将被删除,并
我正在测试Google Drive API。测试脚本执行HTTP GET来访问Files-> List API,但是我总是以某种方式在项目中得到一个空列表。我的Google驱动器中有数百个文件,因此结
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
我将我的应用程序的文件托管在 Google Drive 上,它会在首次启动后立即下载它们。一切都很好,但在我发布新的应用程序版本后,下载数量不断增加,文件由于某些原因变得不可用。虽然我没有改变任何东西
我是一名优秀的程序员,十分优秀!