- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 ACTION_OPEN_DOCUMENT Intent 来启动系统文件选择器。用户应该选择一个“gpx”文件(blabla.gpx)。
我希望选择器只允许选择带有“.gpx”扩展名的文件。
MIME 类型为“application/gpx+xml”,但是当我在 Intent 的 settype() 中指定该类型时,gpx 文件不可选。
有没有办法创建“application/gpx”的自定义 mime 类型,仅供在我的应用程序中使用?如果是这样,如何将其与“,gpx”文件扩展名关联起来?
也许我可以更改与“application/gpx+xml”mimne 类型关联的文件扩展名?
或者,还有其他方法可以完成我想做的事情吗?
最佳答案
I am using a ACTION_OPEN_DOCUMENT intent to launch a system file picker.
ACTION_OPEN_DOCUMENT
不限于文件。
I would like to have the picker only allow files with a ".gpx" extension to be selected.
ACTION_OPEN_DOCUMENT
不限于使用文件扩展名的文档提供程序。和GPX-formatted content不限于扩展名为 .gpx
的文件。
There is a MIME type of "application/gpx+xml", but when I specify that in the intent's settype(), the gpx files are not selectable.
在 Android SDK 模拟器或 Google Pixel 设备上试用。如果您遇到同样的问题,请提交错误报告。
但是,请记住,MIME 类型和关联文件扩展名的列表可能由设备制造商自定义。这就是为什么我建议在 SDK 模拟器或 Google Pixel 上进行测试,因为这些都是纯 Google 的,因此任何问题均由 Google 负责。我同意 .gpx
是 GPX 内容的常见文件扩展名,因此 ACTION_OPEN_DOCUMENT
和 application/gpx+xml
应该允许用户选择它内容。
Is there a way to create a custom mime type of "application/gpx", just for use in my app?
不,抱歉,至少不会影响 ACTION_OPEN_DOCUMENT
。
Maybe I could change the file extension associated with the "application/gpx+xml" mimne type?
不,抱歉,除了我建议的错误报告之外。
is there another way to accomplish what I want to do?
不完全是。
关于java - 如何为 ACTION_OPEN_DOCUMENT Intent 实现自定义 MIME 类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59968229/
在我的应用程序中,我想为用户提供一种从应用程序的数据目录中选择文件的方法。这是我的代码: // use ACTION_OPEN_DOCUMENT because ACTION_GET_CONTENT
我想在我的小米设备上使用 ACTION_OPEN_DOCUMENT。我试过 this google sample ,但它也不起作用。使用下面的代码,我可以正常运行在 Samsung galaxy s4
我正在使用此处指定的新 Kitkat 存储访问框架 (SAF): https://developer.android.com/guide/topics/providers/document-provi
我想使用作为存储访问框架的一部分提供的 android 系统对话框打开文件。我用 Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); in
我有 AddActivity,它可以让您从相机拍摄的照片或从图库中选择的图像中获取 URI。然后就可以去DetailsActivity查看图片了。在您重新启动设备之前,我现在可以正常工作。在您重新启动
我想在特定路径打开文件选择器。用户应该能够选择手机上的任何文件,但 SAF 应首先显示特定文件夹。我尝试了以下方法,但它总是打开下载文件夹。谢谢! Intent intent = new Intent
我想获取我使用 Intent.ACTION_OPEN_DOCUMENT 选择的文件的文件扩展名。如何获取? 这就是我启动选择器的方式: private void startFilePicker(){
我很难理解 ACTION_OPEN_DOCUMENT 和 ACTION_GET_CONTENT Intent 用于打开可打开文档时之间的区别。如果我在 KitKat 之前支持 Andriod,它不支持
我尝试附上一些照片(或其他!文档),这些照片是通过手机相机(或其他!应用程序 - 用于创建文档)制作的。如果我运行下面的代码来选择照片,我没有看到它们: Screenshot from the App
当我尝试使用打开 .json 文件时 startActivityForResult(Intent(Intent.ACTION_OPEN_DOCUMENT).apply { addCategor
我正在使用 ACTION_OPEN_DOCUMENT Intent 来启动系统文件选择器。用户应该选择一个“gpx”文件(blabla.gpx)。 我希望选择器只允许选择带有“.gpx”扩展名的文件。
当用户选择文件夹而不是文件时,我希望能够从 DocumentFile 访问文件列表。我这样称呼 Intent : Intent intent = new Intent(Intent.ACTION_OP
我正在使用 android pie 中的 Retrofit 制作个人资料照片更改功能。 这样我就成功的把相机拍的照片上传到服务器了。但我不知道如何将从图库中选择的照片传输到我的服务器。(我可以使用 J
我希望 SAF“在指定文档中启动导航器,如果它是一个文件夹”(他们在文档中这样调用它)。 这不起作用,所以我也想知道我是否可以将存储快捷方式添加到 SAF UI。请参阅此链接中的图片: https:/
我需要编写一个 Android 应用程序来观察另一个应用程序何时修改文件,然后从中读取数据。该文件由用户选择。所以我想使用 Intent 以及设备上可用的文件选择器供用户选择文件。 使用 Intent
我正在尝试编写一个自定义 DocumentsProvider,它允许其他应用程序对其提供的 Uris 获取持久权限 我有一个 DocumentsProvider,我在我的 AndroidManufes
在我的一个 android 项目中,我在装有 Android 5.0.2 的三星平板电脑上遇到了以下问题:从 fragment 中,用户可以开始选择一个文件: private static final
我正在使用 react-native-firebase和 react-native-document-picker我正在尝试关注 face detection tutorial . 尽管通过 Perm
我是一名优秀的程序员,十分优秀!