Search code examples
androidgmailattachmentintentfilter

android gmail opening app attachment URI issue with new Gmail app version


I have the following intent filter in my Manifest. This code used to work fine on a Nexus 7 with Android 4.2.2 until 2 days ago when Google did an update to their Gmail app. My application no longer shows up in the proposed list of app that can open this type of attachment. If I uninstall the updates, it works back... Any idea as to what I can do to get it working again?

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data
        android:host="*"
        android:mimeType="application/octet-stream"
        android:pathPattern=".*.grb"
        android:scheme="content" />
</intent-filter>

Solution

  • I have looked everywhere for a solution, and unfortunately with this version of gmail the only differentiator will be the mime type and scheme. The reason is that Gmail Uris now are in this format:

    content://gmail-ls/[email protected]/messages/1162/attachments/0.1/BEST/false
    

    Obviously there is no filename or extension here so your options all involve making the filter more generic - You could remove only the pathPattern part of your filter, matching all results for host=*, scheme=content, mimeType=application/octet-stream

    or alternatively make your filter even more generic. You can match every mimetype with the following:

    <intent-filter>
        actions
        categories
        <data android:mimeType="application/*" />
        <data android:mimeType="audio/*" />
        <data android:mimeType="image/*" />
        <data android:mimeType="message/*" />
        <data android:mimeType="multipart/*" />
        <data android:mimeType="text/*" />
        <data android:mimeType="video/*" />
    </intent-filter>
    

    Note I found android:mimeType="*/*" also appears to work on ICS, but I am not sure whether this is backwards compatible with older droids. If you conclude anything about this, please post! It might not work judging by some responses here:

    Intent Filter to capture all sharing Intents