Android 可用的 MIME 类型?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23385520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:04:43  来源:igfitidea点击:

Android available mime-types?

androidmime-types

提问by JoaoFilipeClementeMartins

After several searches online, I couldn't find a place that could tell me every existent mime type for different types of media in android applications.

在网上搜索了几次之后,我找不到一个地方可以告诉我 android 应用程序中不同类型媒体的每种存在的 mime 类型。

Here are the ones I know that exist and work:

以下是我所知道的存在和工作的:

For Text

对于文本

"text/plain"

For Image

对于图像

"image/jpeg"
"image/bmp"
"image/gif"
"image/jpg"
"image/png"

For Video

对于视频

"video/wav"
"video/mp4"

These are the ones I have and know that work, I am lacking several for video and sound type files. Does anyone know a place where every android mime-type is described or do you guys ever used another mime-type for these different types of media?

这些是我拥有并知道可以工作的文件,我缺少一些用于视频和声音类型文件的文件。有谁知道描述每个 android mime-type 的地方,或者你们是否曾为这些不同类型的媒体使用另一种 mime-type?

EDIT:

编辑:

I am using this in an application that monitors SMS and MMS and in the MMS type manages the content inside it. The code I have runs for every version above 8.

我在监控 SMS 和 MMS 的应用程序中使用它,并在 MMS 类型中管理其中的内容。我为 8 以上的每个版本运行的代码。

采纳答案by tianya

I did some search these days.

这几天我搜了一下。

maybe you shoud read these links.

也许你应该阅读这些链接。

回答by CommonsWare

I couldn't find a place that could tell me every existent mime type for different types of media in android applications

我找不到一个地方可以告诉我 Android 应用程序中不同类型媒体的每种现有 mime 类型

There are over a million applications on the Play Store, plus others elsewhere (e.g., pre-installed on devices, Amazon AppStore for Android). A given device will have some combination of these apps. A given user will have access to some subset of the apps on the device, if the user is running in an Android 4.3+ restricted profile on a tablet.

Play 商店上有超过一百万个应用程序,以及其他地方的其他应用程序(例如,预装在设备上、适用于 Android 的 Amazon AppStore)。给定的设备将具有这些应用程序的某种组合。如果用户在平板电脑上运行 Android 4.3+ 受限配置文件,则该用户将有权访问设备上的某些应用子集。

Hence, there is no way to know, at compile time, what MIME types a given Android device can support for things like ACTION_VIEWactivity requests. The OS itself supports no such MIME types -- they are all provided by applications.

因此,在编译时无法知道给定的 Android 设备可以支持哪些 MIME 类型来支持诸如ACTION_VIEW活动请求之类的事情。操作系统本身不支持这样的 MIME 类型——它们都是由应用程序提供的。

Here are the ones I know that exist and work:

以下是我所知道的存在和工作的:

Some devices may have apps pre-installed that support those MIME types. text/plainis the least likely of your set to be supported "out of the box".

某些设备可能预装了支持这些 MIME 类型的应用程序。text/plain是您的套装中最不可能“开箱即用”的。

回答by StrawDragon

You can use existing mapping in Android String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext.toLowerCase());

您可以使用 Android 中现有的映射 String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext.toLowerCase());