Search code examples
javaandroidmime

How to implement a custom MIME type for ACTION_OPEN_DOCUMENT intent?


I am using a ACTION_OPEN_DOCUMENT intent to launch a system file picker. The user is supposed to be selecting a "gpx" file (blabla.gpx).

I would like to have the picker only allow files with a ".gpx" extension to be selected.

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.

Is there a way to create a custom mime type of "application/gpx", just for use in my app? If so, how do I associate it with the ",gpx" file extension?

Maybe I could change the file extension associated with the "application/gpx+xml" mimne type?

Or, is there another way to accomplish what I want to do?


Solution

  • I reported this to Google, and here is their response:

    A coworker pointed out that application/gpx+xml is an established MIME type mapped to the file extension.gpx:

    https://en.wikipedia.org/wiki/GPS_Exchange_Format

    We'll consider adding this mapping to a future version of Android.