【发布时间】:2020-09-17 14:14:50
【问题描述】:
我想在我的 Android 应用程序中选择保存在 Google Drive 上的 Google Docs 文件,然后 - 从中读取一些数据(但这超出了这个问题的范围)。所以一开始我只想点击那个文件并得到一些回调。我在 Google Drive Android API Deprecation 上关注 this recommendations 并迁移到 Google Drive Rest API。
我设法与 Google Drive 的文件列表对话,但我无法选择 Google Docs 文件(我可以看到它们,但它们无法点击它们)。同时,如果我设置了它们的 MIME 类型,我可以选择其他类型的文件 - 例如 PDF、PNG。
现在我使用这段代码:
val pickerIntent = Intent(Intent.ACTION_OPEN_DOCUMENT)
pickerIntent.addCategory(Intent.CATEGORY_OPENABLE)
pickerIntent.type = "*/*"
val mimeTypes = arrayOf(
"application/pdf", // works
"image/png", //works
// none of MIME below works
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.google-apps.document",
"application/vnd.google-apps.file"
)
pickerIntent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
在official sample 中,他们以 MIME "text/plain" 为例,所以对我没有帮助。
我尝试了几种可以找到的 MIME 类型(例如 here 和 here),但都没有解决问题。
应该为此使用什么 MIME 类型?或者问题可能不在 MIME 类型中?
【问题讨论】:
标签: android google-drive-api google-docs google-drive-android-api