1

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.

Authman Apatira
  • 3,994
  • 1
  • 26
  • 33
  • Okay, using the response here http://stackoverflow.com/questions/4675257/custom-filetype-in-android-not-working I was able to get the 2nd part (SDCARD file system portion) working. But the first part, the HTTP portion isnt working. – Authman Apatira Jan 18 '12 at 00:15

3 Answers3

6

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>
Community
  • 1
  • 1
Authman Apatira
  • 3,994
  • 1
  • 26
  • 33
  • Thanks alot @Authman .. I am trying to do the same thing, research alot and tried hundreds of Intent filters, but finally your code works..Thanks alot!! – Kanika May 18 '12 at 07:31
0

You can try changing the below attributes

android:mimeType="text/*"
android:pathPattern="*.mht"

to your intent-filter

General Failure
  • 2,421
  • 4
  • 23
  • 49
0

When retrieving the files from your web site, can you verify what the content types are in the two files? I would expect different behavior if they showed a different type (maybe the web server is interpreting the data and seeing different triggers in each file).

I checked the headers at http://web-sniffer.net/, and the second file doesn't exist anymore so I can't compare.

Another wrinkle that might affect things - unless you set the user agent to match what your Android devices will be using, you might get a different result on your desktop browser or web-sniffer.

Not sure if that's what is causing your problem, but it's worth verifying.

ProjectJourneyman
  • 3,566
  • 1
  • 27
  • 37
  • Sorry about that. I just put the 2nd file back up. I am clicking on the links from the GMail Android client, so I'm not sure if it checks the headers before firing off the intent. But for example if I copy keepme.mht onto my SD card and double click it, it gives me the context menu. But the same keepme.mht on a web link doesnt (i've compared the contents of the dl'd file and the original and they were identical) – Authman Apatira Jan 18 '12 at 00:30
  • 1
    Hmm. It's possible that the browser does some checking and decides what the content type is by the data. I see that the two files use a different charset, which might be related. The second file also has some additional lines at the top. Maybe you'll need to do some investigation to see what type it is processing the second file as, and add a filter to capture that too. – ProjectJourneyman Jan 18 '12 at 07:06