如何启用具有意图的选择Google Docs文件(保留在Google云端硬盘上?)>

问题描述 投票:1回答:1

我想在我的Android应用中选择保存在Google云端硬盘中的Google文档文件,然后再从其中读取一些数据(但这不在此问题的范围内)。因此,一开始我只想单击该文件并获得一些回调。我遵循Google Drive Android API弃用this recommendations并迁移到Google Drive Rest API

我设法获得了有关Google云端硬盘文件列表的对话框,但是我无法选择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类型(例如herehere,但是它们都没有解决问题。

应为此使用哪种MIME类型?还是问题不在于MIME类型?

我想在我的Android应用中选择保存在Google云端硬盘中的Google文档文件,然后再从其中读取一些数据(但这不在此问题的范围内)。因此,一开始我只想...

android google-drive-api google-docs google-drive-android-api
1个回答
0
投票

我在this official documentation's article中发现了问题的根源。

© www.soinside.com 2019 - 2024. All rights reserved.