Search code examples
androidandroid-manifestmime-typesfile-association

Android File Associations


My Manifest:

<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="http" android:host="*" android:pathPattern=".*mht" />
    <data android:scheme="https" android:host="*" android:pathPattern=".*mht" />
</intent-filter>
<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:mimeType="message/rfc822" android:scheme="http" />
    <data android:mimeType="multipart/related" android:scheme="http" />
    <data android:mimeType="message/rfc822" android:scheme="https" />
    <data android:mimeType="multipart/related" android:scheme="https" />
</intent-filter>

Results:

Very curious, no? What am I doing wrong here? Equally as weird -- my manifest:

<intent-filter
    android:icon='@drawable/ic_launcher'
        android:label='AndroidMHT File'
    android:priority='1'>
    <action android:name="android.intent.action.VIEW" />
    <action android:name="android.intent.action.EDIT" /> 
    <action android:name="android.intent.action.PICK" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="file" />
    <data android:scheme="content" />
    <data android:mimeType="*/*" />
    <data android:pathPattern=".*\\.mht" />
    <data android:host="*" />
</intent-filter>

Results:

  • /mnt/SDCARD/Android/data/com.mht/files/flipie.mht <--- chooser does not display my program as an option
  • /mnt/SDCARD/Android/data/com.mht/files/keepme.mht <--- chooser displays my program as an option

I'm at ends whit. Any assistance much appreciated.


Solution

  • The suggestions in the first answer here helped me: Android intent filter: associate app with file extension

    This is my new manifest, for those who may benefit from it:

    <intent-filter
        android:icon='@drawable/ic_launcher'
            android:label='AndroidMHT File'
        android:priority='1'>
        <action android:name="android.intent.action.VIEW" />
        <action android:name="android.intent.action.EDIT" /> 
        <action android:name="android.intent.action.PICK" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:mimeType="*/*" />
        <data android:pathPattern="*.mht" />
    </intent-filter>
    <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="http" android:host="*" android:pathPattern=".*\\.mht" />
        <data android:scheme="https" android:host="*" android:pathPattern=".*\\.mht" />
    </intent-filter>
    <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:mimeType="message/rfc822" android:scheme="http" />
        <data android:mimeType="multipart/related" android:scheme="http" />
        <data android:mimeType="message/rfc822" android:scheme="https" />
        <data android:mimeType="multipart/related" android:scheme="https" />
    </intent-filter>