Reputation: 714
I want to be able to open XML files in my app, when the user tries to open an xml file. There are many similar questions but I've tried a lot of them and nothing seems to help.
When I use these intent filters for PDF files it works perfectly (for PDF), but when I replace both mentions of 'pdf' with 'xml' it doesn't work for XML files even if the files are in the same folder.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file"
android:host="*"
android:pathPattern=".*\\.pdf" />
</intent-filter>
Upvotes: 5
Views: 2310
Reputation: 1006614
You have two <intent-filter>
elements.
The first relies on a MIME type. application/xml
is a possible MIME type for an XML file, but so is text/xml
. And, for certain XML files, another MIME type might be used, based on the content of the XML (e.g., application/atom+xml
for content written using the Atom schema). File managers and other "generic" content managers will tend to use whatever MIME type that MimeTypeMap
reports for the file extension. Other apps, such as email clients and Web browsers, will use the MIME type reported by the server.
The second relies on a scheme (file
) and a file extension (.xml
). The file
scheme is slowly fading away, and so this particular <intent-filter>
will not be used much in the future.
Upvotes: 1