Android available mime-types? - android

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.

I did some search these days.
maybe you shoud read these links.
MediaStore supported MIME type is here: http://androidxref.com/4.4.4_r1/xref/frameworks/base/media/java/android/media/MediaFile.java#174
And there is also a API URLConnection.getFileNameMap()
And its inner side is here: http://androidxref.com/4.4.4_r1/xref/libcore/luni/src/main/java/libcore/net/MimeUtils.java

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());

I know I'm late to the party, but I found a full list of mime types here:
https://android.googlesource.com/platform/external/mime-support/+/9817b71a54a2ee8b691c1dfa937c0f9b16b3473c/mime.types

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:
Consult the list Supported media formats from the official Android documentation.
For each media format and each of its possible container formats, find the associated MIME types from the official IANA Media Types list.
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.

Related

Android: associating a new file suffix with an existing MIME type?

I asked a similar question in the Android Enthusiasts stackexchange forum, but no answer has been offered. I'm posting this question here, in hopes that possibly more people will see it and perhaps supply an answer.
This is the Android Enthusiasts post:
https://android.stackexchange.com/questions/203123/oreo-associating-an-app-with-all-files-with-a-given-extension
In summary, I am looking for a way to tell my Oreo-based Android system to associate a new suffix with the text/plain MIME type. In other words, suppose that I want all files on my device with the suffix .abc to be considered to be text/plain. I want this to be a system-wide mapping, not just a mapping for a particular app.
To be clear, I am not simply looking for a way to associate an app with text/plain. What I am looking for is a way to cause all files with this .abc suffix to always be considered to be text/plain on my device.
I know that there are some suffix-to-mime-type mappings under Android. For example. .txt is always mapped to text/plain, as is .log and a number of other suffixes. So at least theoretically, it should be possible to map any suffix (such as my .abc example) to text/plain. However, I haven't been able to figure out how to do this.
There is a file called /system/lib/content-types.properties which seems to offer this capability (see below for a listing of that file from my device). However, when I put abc=text/plain into that file, items with an .abc suffix are still not recognized as text/plain, even after a reboot.
I'm running a rooted device with Xposed and Magisk, and so I can install unoffical modules. However, I haven't found any Xposed or Magisk modules which offer this capability. I am also able to run custom init.d scripts, in case there might be some way to enable this capability in that manner.
Can anyone suggest any way I can accomplish what I want? Thank you very much.
Here are the contents of my /system/lib/content-types.properties file ...
# If you want to support more recognized mimetypes in libcore.net.MimeUtils, add them here
docm=application/vnd.ms-word.document.macroenabled.12
xlsb=application/vnd.ms-excel.sheet.binary.macroenabled.12
xlsm=application/vnd.ms-excel.sheet.macroenabled.12
ppsm=application/vnd.ms-powerpoint.slideshow.macroenabled.12
ppsx=application/vnd.openxmlformats-officedocument.presentationml.slideshow
pptm=application/vnd.ms-powerpoint.presentation.macroenabled.12
asm=text/x-asm
cc=text/x-c
conf=text/plain
cpp=text/x-c
css=text/css
c=text/x-c
cxx=text/x-c
def=text/plain
dic=text/x-c
f77=text/x-fortran
f90=text/x-fortran
for=text/x-fortran
f=text/x-fortran
hh=text/x-c
hpp=text/x-c
h=text/x-c
ics=text/calendar
ifb=text/calendar
in=text/plain
jad=text/vnd.sun.j2me.app-descriptor
java=text/x-java-source
ksh=text/plain
list=text/plain
log=text/plain
pas=text/x-pascal
pl=text/plain
properties=|
prop=text/plain
p=text/x-pascal
py=text/x-python
rc=text/plain
sgml=text/sgml
sgm=text/sgml
s=text/x-asm
vcs=text/x-vcalendar

In android multimedia framework how we decide which decoder will play this video if we have multiple decoder of same MIME type

We have integrated some customer decoder with android multimedia framework by writing OMX component.
When we play video usually we have mime type of VIDEO like video/avc.
If we have multiple decoder component of same mime type, so where we decided or how in android multimedia framework ?
Can anybody point that particular AOSP code or can explain how this happen ?
There has been a related question on this topic where majority of the steps were covered in this answer.
In the parseXML function, the list is populated by going through the media_codecs.xml file and the codecs are listed in the order in which they are listed i.e. first codec in the file will be the first one in the list to be tried, when we have multiple codecs for same MIME type.
In case one wishes to ensure that their custom codec is employed, it should be enlisted as the first codec in the media_codecs.xml for easier integration.

Android types "vnd.android"

What means vnd.android (vnd.android.cursor.dir)?
Where can I find full list and description about this types?
I found this page http://en.wikipedia.org/wiki/Internet_media_type but this is not a complete list. Please give any link of full media type list.
Advance Thanks
The vnd. prefix on a MIME type is a "vendor prefix", meaning that it is not an official IETF MIME type.
vnd.android.cursor.dir is part of a faux MIME type used for database-style ContentProviders in Android, specifically for Uri values that map to what logically would be considered "tables" or "views" (collections of content). For example, the AOSP Contacts application has activities that will respond to a MIME type of vnd.android.cursor.dir/contact. You can find various other uses of vnd.android by filling that into the search field in the Android developer documentation.
Where can I find full list and description about this types?
There is none that I am aware of. Vendor-prefixed MIME types can be used or defined by anyone.

store html on nfc tag

can NFC tags readers, especially on Android, open a webpage stored on the tag after being scanned?
I don't want to store a URL, I want to store a webpage in plain text and have that render after it is scanned. Is this supported?
<html><body>No signal? Bookmark this page!<img src="http://bit.ly/example"/>Test Image</img></body></html>
The above example is only 106 bytes, so can fit on most NFC tags, would this open in a webpage or can there be certain instructions to render it as a webpage?
If you set the MIME type of the tag to text/html, it is possible that this will be rendered in browsers set up to read NFC tags containing that MIME type. Whether there are any such browsers, I cannot say. The AOSP Browser app does not support this -- the only NFC tags it supports are ones with http or https schemes for URLs, based on the current contents of its manifest.
Yes you can store a web page on an NFC tag - in fact you could store anything. That does not mean that it is a good idea. If you do not decide on the tags to be used, html is a bad idea. Rather store an URL and get the data online. Or store the data in a more compact format.
EDITED ADDITIONAL INFO:
The Android Developer site at this link:
https://developer.android.com/guide/topics/connectivity/nfc/nfc
contains a wealth of information which, upon reading, explains why this particular approach is challenging, but also inspires a while heap of other alternative ideas, methods, ways and means... I strongly recommend checking it out!!!
********** End Of Edit ************
ORIGINAL ANSWER:
I have experimented with the very same, and created a custom NDEF message of MIME type text/html, with a fully coded HTML document as text in the data field of said MIME type ( & all standard tags such as & & so on). I have not had any luck with having the page rendered in a browser window. Usually, on scanning the NFC chip, it just returns a new-tag response showing my MIME "text/html" prefix, and completely omits the display of even the associated HTML encoding!
It's very frustrating..
However - in going to try again, as I understand that a recent release of Chrome Browser has a flag for experimental NFC features that can be activated.
In the Chrome Browser, navigate to chrome://chrome-urls and choose the flags link (or just go straight to chrome://flags ), then in the search bar type NFC. When the two or so options are presented, change the flags from default to enabled.
Now, I know that this then allows websites to interact with data on NFC tags, and allows you to script the content fields as variables, etc etc etc, but I DON'T know if it will solve our "render MIME type text/html record as web page directly" problem.
I will test it out and let you know...
I had a similar thought to you and was investigating this idea. However android by default do not have an app that can recognize such tag by default... not even android chrome.
But what I did end up doing to explore this was to create an NFC tag project that can generate a tag with a mime record of text/html or text/html+gzip (FYI: text/html+gzip technically is not an officially registered mime record type, however I think it still keeps to the normal semantic of other mime record that combines a format + compression). It's located at https://github.com/mofosyne/js-ndef-html-tag to generate a tag.
As for viewing it, I've created an experimental android app where I have also placed an intent hook for both text/html or text/html+gzip so that any NFC tag with such content will automatically open up https://github.com/mofosyne/NFCMessageBoard and display the tag's html content.
However ideally you would push android to add native support for viewing html tags directly.
Until then, the official answer is no you cannot.

iOS equivalent to Android MODE_WORLD_READABLE

As the title says - is there something in iOS that lets you say 'this file is allowed to be accessed by other apps' - preferably only readable, but read/write would be good enough.
Basically I am trying to place a file outside the sandbox so other apps can read it - preferably via the openURL that points to a local file rather than an http address.
Thanks
Edit:
I just received an answer from Apple Tech support and they told me that this is currently impossible (just after iOS 6 released)
I don't think it's possible to do it the way you describe. Last I checked, apps can only write inside their sandbox dir and cannot read inside other apps' sandboxes (though IIRC there used to be a few other writable directories).
What, exactly, is the end result you are trying to achieve?
If you know the app you want to read the data, you can use a custom URL scheme.
If you have a file of a certain type (extension/content-type, I think), you can use UIDocumentInteractionController to let the user pick an app to open it in.
If you just want to share some data with any app, the closest I can think of is a custom UIPasteboard. OpenUDID does this for a slightly dubious purpose.

Categories

Resources