2

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>
arober11
  • 1,969
  • 18
  • 31

3 Answers3

2

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>
arober11
  • 1,969
  • 18
  • 31
2

You don't need really to play, here is a quick roundtrip to find out what you need.

  1. Grep logcat for "ActivityManager: START u0"
  2. Place your file in Downloads
  3. Open Download App
  4. Open your file by click on it
  5. Check logcat you should find a line like: {act=android.intent.action.VIEW dat=content://com.android.providers.downloads.documents/document/2183 typ=text/csv flg=0x3 ...

This means your scheme is "content" and your mime type is "text/csv". As a hint when you see the dialog "open with" leave it open and do a ./gradlew installDebug with your new filter settings and it will immediately appear when you hit the filter conditions in your manifest set.

drindt
  • 901
  • 10
  • 15
0

This works for me

   <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:host="*" />
            <data android:scheme="content" />
            <data android:mimeType="text/*"/>
        </intent-filter>
Devinder Jhinjer
  • 645
  • 7
  • 13