【问题标题】:How to select files from google drive in android?如何在android中从谷歌驱动器中选择文件?
【发布时间】:2013-08-13 20:42:18
【问题描述】:

有没有办法在 android 应用程序中启动 google 驱动器的文件选择器 - 执行类似于 http://googleappsdeveloper.blogspot.com/2012/08/allowing-user-to-select-google-drive.html 的操作。我需要允许用户从谷歌驱动器中选择文件,这样我就可以在我的应用程序中使用它们的字节。谢谢。

【问题讨论】:

  • 你有没有找到任何相关的教程?

标签: android google-drive-api google-drive-android-api filepicker


【解决方案1】:

是的,GDAA 中有一个文件选择器。看到它使用的最佳位置是this demo,特别是Intents 部分。

你感兴趣的演示中有2个方法:

  1. “使用开启活动选择文件”,
  2. 以及“使用开启活动选择文件夹”

但它们本质上是相同的,只是此处指定的 MIME TYPE 过滤器不同:

IntentSender intentSender = Drive.DriveApi.newOpenFileActivityBuilder()
 .setMimeType(new String[] { DriveFolder.MIME_TYPE })  // <--- FOLDER
 //.setMimeType(new String[] { "text/plain", "text/html" }) // <- TEXT FILES
 .build(getGoogleApiClient());

祝你好运

【讨论】:

  • 转到here,找到“意图”部分,点击离开...
  • 为此,您必须在 GoogleApiClient 成功连接后调用此意图(可能在覆盖的 onConnected(Bundle hints) 方法中)
  • @seanpj 可以在没有 Intent 和使用 GDAA 的情况下默认选择一个文件夹(不在应用程序中创建)?
  • Drive Android API 已于 2018 年 12 月 6 日弃用,并将于 2019 年 12 月 6 日停用。developers.google.com/drive/android/deprecation
【解决方案2】:

有一个用于此的 api。我认为这个 google 的文档应该对 https://developers.google.com/drive/android/queries 有所帮助。我不确定你想怎么做。

【讨论】:

  • 请注意,截至 2018 年 12 月,此链接中的 API 现在正处于被 Google 弃用的过程中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-10-19
  • 2022-12-15
  • 1970-01-01
  • 2022-11-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多