Intent Filter to Download Attachment from Gmail Apps on Android

Downloading attachment from g/email in Android

GMail doesn't let you click URL's with unknown schemes, so you can use the schema that beginning with "http://".
To define in manifest do something like this:

<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="com.yourdomain.yourapp"/>
</intent-filter>

Reading gmail attachment in my app

The answer appears to be that the activity was set to be 'single instance' for various reasons. This means that whilst it is brought to the foreground again, it comes back with the intent it was originally started with, not the one created by gmail.

Removing the 'single instance' attribute allowed the correct intent to be used.

Android: File Extension Intent Filter does not work properly with GMail/Downloads app

I got it working by putting content into its own intent-filter group along with a file data scheme, both having a mime-type of application/octet-stream.

        <intent-filter android:priority="999" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.OPENABLE" />

<data
android:scheme="http"
android:host="*"
android:pathPattern=".*\\.sbu" />

<data
android:scheme="https"
android:host="*"
android:pathPattern=".*\\.sbu" />

<data
android:scheme="ftp"
android:host="*"
android:pathPattern=".*\\.sbu" />

<data
android:scheme="ftps"
android:host="*"
android:pathPattern=".*\\.sbu" />

<data
android:scheme="file"
android:host="*"
android:pathPattern=".*\\.sbu" />
</intent-filter>

<intent-filter android:priority="999" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.OPENABLE" />

<data
android:scheme="file"
android:mimeType="application/octet-stream"
android:pathPattern=".*\\.sbu" />

<data
android:scheme="content"
android:mimeType="application/octet-stream"
android:pathPattern=".*\\.sbu" />
</intent-filter>


Related Topics



Leave a reply



Submit