- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试打开最近的窗口,该窗口只能选择图像和 pdf
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
但在这里我只能选择图像我还可以添加 pdf
最佳答案
您可以使用 EXTRA_MIME_TYPES(来自 API 19)执行以下操作:
final String[] ACCEPT_MIME_TYPES = {
"application/pdf",
"image/*"
};
Intent intent = new Intent();
intent.setType("*/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra(Intent.EXTRA_MIME_TYPES, ACCEPT_MIME_TYPES);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
更新
还有另一种解决方案,但它可能会或可能不会根据用户体验而定,但您可以尝试一下,看看它是否适用于您的情况:
intent.setType("image/*,application/pdf");
但是您尝试调用的应用程序也应该支持 MIME 类型
关于android - Intent.ACTION_GET_CONTENT 打开图片和pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36565561/
我正在使用 ACTION_GET_CONTENT,以便用户可以选择我的其余代码可以读取和处理的文本文件。 Intent intent = new Intent(); intent.setAction(
我在使用 ACTION_GET_CONTENT 从 Downloads 目录中选择文件时遇到问题。 如果我在本地存储中的 ES 资源管理器或文件管理器中删除任何文件,在我的应用程序中打开时,这些已删除
好的,我用这个开始我的功能 Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(mimeType
我在我的应用中实现了一个文件选择器,如下所示: Intent intent = new Intent(); intent.setType("*/*"); intent.setAction(Intent
Google Drive 似乎有一个响应 GET_CONTENT 操作的 Activity ,但它没有导出。 我可以在我的应用程序中使用另一种方法从云端硬盘中提取内容,而无需从 云端硬盘启动流程吗?自
我有以下 Intent : Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("text/*"); start
我正在为我的 Android 应用实现导入功能。我想让用户选择他们想要从设备上的外部存储(确切地说是下载目录)和其他在线文件存储(例如 DropBox 和 Google Drive)导入的文件。 我在
流程是: 用户需要选择要使用的文本文件以及弹出的默认 Android 资源管理器。 然后我想存储包含文件名的字符串,以实际打开文件进行读取。 我想打开该文件并将其重写为应用内部存储上的新文件。 我想从
我正在尝试打开最近的窗口,该窗口只能选择图像和 pdf Intent intent = new Intent(); intent.setType("image/*"); intent.setActio
我正在尝试将文件选择器 Intent 中的选定文件(不限于图像,它可以是任何文件)放入一个 zip 文件。我需要完整的文件路径才能执行此操作,但 Intent 仅提供 uri 路径。 我试过 .get
我有一个使用 ACTION_GET_CONTENT 的已发布应用程序 Intent 让用户选择他/她的一张照片。这是启动 Intent 的代码: Intent intent = new Intent(
我正在尝试在 android 应用程序中阅读 pdf 文件。 触发以下 Intent 以获取 URI。 Intent intent = new Intent(Intent.ACTION_GET_CON
我的问题很简单。是否可以通过 Intent.ACTION_GET_CONTENT 以某种方式传递额外的数据?其中Activity收到Intent在它的onActivityResult()能读出吗? 现
我需要完成这些步骤: 让用户选择一个文件(任何类型的文件) 获取永久引用以便稍后访问文件或复制到我的内部存储。 第一个真的很简单。使用 Intent.ACTION_GET_CONTENT 获取文件没有
我正在尝试获取用户选择的文件的路径,为结果调用 intent ACTION_GET_CONTENT。 问题是当从文件管理器中选择一个音频文件时, Intent 不返回文件的扩展名(我检查过的文件名中有
我试图只显示 MP3 文件: Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("audio/mp3"); s
Web 和 stackoverflow 包含几个示例如何使用 ACTION_GET_CONTENT Intent 从另一个 Android 应用程序获取文件(例如,将其用作电子邮件附件)。但是我必须实
我正在开发一个应用程序,在此 Activity 中按下一个按钮,可以选择要上传的任何文件。文件选择器加载正确,但所有图像都无法选择(变灰)。我在 Manifest 文件中添加了 READ_EXTERN
在我的应用中,我需要从用户的库中获取音频文件。 为此,我将其称为 Intent: Intent selectIntent = new Intent(Intent.ACTION_GET_CONTENT)
作为docs说:“ACTION_GET_CONTENT 可以让用户浏览网络并下载所需的数据”。这就是我需要的,来自 Google Images。虽然,如果我使用此 Intent 的类型,应用程序会崩溃
我是一名优秀的程序员,十分优秀!