Question

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.

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 have you guys ever used another MIME type for these different types of media?

EDIT:

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

Était-ce utile?

La solution

I did some search these days.

maybe you shoud read these links.

Autres conseils

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

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.

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

Here are the ones I know that exist and work:

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

You can use existing mapping in Android (java version)

String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext.toLowerCase());

Which MIME types does Android support out of the box?

Since that's your immediate question, let's answer that first (though it's not exactly the right question for your MMS usecase).

To know the MIME types supported by Android itself (not considering additional apps), you can use this process:

  1. Consult the list Supported media formats from the official Android documentation.

  2. For each media format and each of its possible container formats, find the associated MIME types from the official IANA Media Types list.

  3. Since there are some unregistered MIME types in use in practice, including by Android, additionally consult the list of MIME types known to the Android platform to convert the supported media formats. For example, the Matroska video container format (.mkv files) appears only in that list, not in the IANA list.

Which MIME types might you encounter in MMS?

tell me every existent mime type for different types of media in android applications. […] I am using this in an application that monitors SMS and MMS and in the MMS type manages the content inside it.

For your case, the MMS standard will tell you what MIME types can be used for its content. And it seems that, like e-mail, MMS does not restrict what MIME types its content can be. For example, one supplier of MMS solutions tells that it will simply pass content with unknown MIME types to the network carrier:

If the format is not listed below that means it still gets accepted on the API, but […] it may get delivered to the carrier or may not depending on the size of the content. (source)

Since applications can define their own MIME types, including types starting with prs. and x. that cannot be registered at IANA, you cannot know beforehand which MIME types you will encounter.

So for practical purposes, it is the safest approach if your application can deal with all MIME types supported by the Android platform by default – see above for the list. And then handle everything else (added by apps) in a generic manner.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top