My app can open the following file formats:
- kml (application/vnd.google-earth.kml+xml)
- kmz (application/vnd.google-earth.kmz)
- gpx (application/gpx+xml)
I'm trying to set up properly my intent filters so that my app is proposed when trying to open one of these file types, through the following schemes:
- http
- https
- file
- content
I would expect the following filter to catch all cases (except files with dots in the name, but that's another problem):
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:scheme="content" />
<data android:pathPattern=".*\\.kml" />
<data android:pathPattern=".*\\.kmz" />
<data android:pathPattern=".*\\.gpx" />
<data android:mimeType="application/vnd.google-earth.kml+xml" />
<data android:mimeType="application/vnd.google-earth.kmz" />
<data android:mimeType="application/gpx+xml" />
</intent-filter>
But if the file explorer does not set properly the GPX content type, GPX files are not recognized (even though they are properly named, with ".gpx" extension).
Does someone know what's the problem?
file
and the extensions. The other is the other schemes and the MIME types. As it stands, for example, if the content has the right MIME type, but the path does not have one of those extensions (as it rarely will forcontent
), your filter will not match. In general, file extensions are the least reliable approach on Android. – Radiotherapyhttp
andhttps
, the MIME type would be more reliable IMHO. Forcontent
, frequently there is no file extension. I tend to take the approach of using a smaller scope that is less likely to give me erroneous results. But, if you want to apply all four schemes in both filters, that probably works. – Radiotherapy