androidintentfilterandroid-download-managerdownload-manager

Android intent-filter to be notified of an attempt to view a CSV file in the Download Manager


What's the required magic incantation to register your app to be notified that a user is trying to view a CSV file they've previously downloaded via the Download manager. I've had a brief play and the following filter will happily intercept notifications generated by: Dropbox, Box, Google Drive, Sky Drive, Chrome..... and offer itself to open the files, but my App isn't getting anything when a user attempts to view a file via the Download Manager.

        <intent-filter>
            <action android:name="com.my.testImportApp.LAUNCH" />
            <action android:name="android.intent.action.SEND" />
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.EDIT" />
            <action android:name="android.intent.action.PASTE" />
            <action android:name="android.intent.action.OPEN_DOCUMENT" />
            <action android:name="android.intent.action.GET_CONTENT" />
            <action android:name="android.intent.action.INSERT" />
            <action android:name="android.intent.action.INSERT_OR_EDIT" />
            <action android:name="android.intent.action.SENDTO" />
            <action android:name="android.intent.action.SEND_MULTIPLE" />
            <action android:name="android.intent.action.PICK" />
            <category android:name="android.intent.category.CATEGORY_BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
            <data android:scheme="http" />
            <data android:scheme="https" />
            <data android:scheme="ftp" />
            <data android:scheme="file" />
            <data android:scheme="data" />
            <data android:scheme="info" />
            <data android:scheme="data" />
            <data android:scheme="smb" />
            <data android:scheme="nfs" />
            <data android:scheme="android.resource" />
            <data android:mimeType="text/comma-separated-values"/>
            <data android:mimeType="text/csv"/>
            <data android:mimeType="text/plain"/>
        </intent-filter>

Solution

  • After a bit of playing, the following appears to work:

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.OPEN_DOCUMENT" />
                <action android:name="android.intent.action.PICK" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.ALTERNATIVE" />
                <data android:scheme="http" />
                <data android:scheme="https" />
                <data android:scheme="ftp" />
                <data android:scheme="file" />
                <data android:scheme="data" />
                <data android:scheme="info" />
                <data android:scheme="data" />
                <data android:scheme="smb" />
                <data android:scheme="nfs" />
                <data android:mimeType="text/comma-separated-values"/>
                <data android:mimeType="text/csv"/>
                <data android:mimeType="text/plain"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.OPEN_DOCUMENT" />
                <action android:name="android.intent.action.PICK" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.ALTERNATIVE" />
                <data android:scheme="http" />
                <data android:scheme="https" />
                <data android:scheme="ftp" />
                <data android:scheme="file" />
                <data android:scheme="data" />
                <data android:scheme="info" />
                <data android:scheme="data" />
                <data android:scheme="smb" />
                <data android:scheme="nfs" />
                <data android:host="*" />
                <data android:pathPattern="/.*\\.csv" />
                <data android:pathPattern="/.*\\.CSV" />
                <data android:pathPattern="/.*\\.txt" />
                <data android:pathPattern="/.*\\.text" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.OPEN_DOCUMENT" />
                <action android:name="android.intent.action.PICK" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.ALTERNATIVE" />
                <data android:mimeType="text/comma-separated-values"/>
                <data android:mimeType="text/csv"/>
                <data android:mimeType="text/plain"/>
            </intent-filter>