I want to be able to download a file with a particular extension from the 'net, and have it passed to my application to deal with it, but I haven't been able to figure out the intent filter. The filetype is not included in the mimetypes, and I tried using
<data android:path="*.ext" />
but I couldn't get that to work.
When an Intent meets a
intent-filter
, these are theintent-filter
requirements: (imagine a checklist).<action>
<category>
<data mimeType>
(easy fix: "/")Optionally:
Any matching
<data scheme>
(easy fix:<data android:scheme="file" /> <data android:scheme="content" />
)Any matching
<data host>
(easy fix: "*")<data pathPattern/etc.>
(for example.*\\.0cc
)Defining multiple
<data $type="">
elements checks the $type box iff any<data $type=>
matches theIntent
.Omitting mimeType breaks your
intent-filter
, even though it's seemingly redundant. Omitting<data scheme/host/pathPattern>
causes your filter to match everything.https://f-droid.org/en/packages/de.k3b.android.intentintercept/ is an app designed to receive all intents, and allows you to inspect the intent. I learned that unrecognized file extensions opened via Simple File Manager are delivered with MIME type
application/octet-stream
.https://stackoverflow.com/a/4621284/2683842 reports that
<data pathPattern=>
.*xyz
aborts at the firstx
it sees, and will fail immediately if not followed byyz
. So/sdcard/.hidden/foo.0cc
will not pass.*\\.0cc
unless you try.*\\..*\\.0cc
instead.End result: