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?
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>
来源:https://stackoverflow.com/questions/2037551/how-to-open-email-attachment-in-my-app-on-android