views:

561

answers:

1

I want to open a specific type of file that my app can already send over email as an attachment. I need to be able to have the android email app choose my app to download or open that specific file type. I can't figure out how to set up an intent filter that would let me do that though. Anyone know how this is done?

+1  A: 

Intent filters generally work based on MIME type of the file. But if you're using a custom file format that Android's not likely to recognise, then it's not as simple. You can maybe try using the android:pathPattern attribute to try and match the filename, but it's not something I've tried.

I imagine you'd use something like this in your <activity> tag:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="*/*" />
    <data android:pathPattern=".*\\.xyz" />
</intent-filter>
Christopher
Turns out I was just missing the action and category tags. The custom mimeType worked just fine, didn't need pathPattern. If there's a way to change the action so it shows the download button instead of preview in the email app, that would be great.
CodeFusionMobile