1

Based on this answer I configured an intent handler for local RTF files. It works well with a file manager app and with the downloaded file view of Firefox on my Nexus 7 (Android 4.4).

The Downloads app - an app which can be launched separately, but shows files downloaded by Chome - does not offer to open chosen RTF files with my app. Instead it displays "Error: Can't open file".

The logcat output is:

W/DownloadManager﹕ Failed to start Intent 
{ act=android.intent.action.VIEW dat=content://downloads/all_downloads/1763 typ=application/rtf flg=0x3 }: 
android.content.ActivityNotFoundException: 
No Activity found to handle Intent 
{ act=android.intent.action.VIEW dat=content://downloads/all_downloads/1763 typ=application/rtf flg=0x3 }-

The same however works well in the emulator (Android 4.0.3): RTF downloaded in the default web browser appear in the Downloads app and can be opened by my RTF viewer.

PDF documents also can be opened directly from the Downloads app.

I also checked that the server where I download the RTF uses one of the specified MIME types (it is application/rtf).

My question is: are there other special requirements to associate an app with the files displayed in the Downloads app view I am missing?

Secondary question: where are the files stored which appear in the Downloads app?

My intent filter:

<intent-filter
            android:icon="@drawable/logo"
            android:label="Tiny RTF">

            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />

            <data android:scheme="http" />
            <data android:scheme="https" />
            <data android:scheme="content" />

            <data android:scheme="file" android:host="*"
                android:pathPattern=".*\\.rtf" />

            <data android:mimeType="application/rtf" />
            <data android:mimeType="text/rtf" />
            <data android:mimeType="text/richtext" />
</intent-filter>

Permissions:

 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Community
  • 1
  • 1
mjn
  • 36,362
  • 28
  • 176
  • 378

1 Answers1

4
  1. My question is: are there other special requirements to associate an app with the files displayed in the Downloads app view I am missing?

Download Manager uses the content scheme type.

Try this:

<data 
    android:scheme="content" 
    android:host="*"
    android:mimeType="application/rtf" />
  1. Secondary question: where are the files stored which appear in the Downloads app?

In my device the downloaded files are stored in : /data/media/0/Download

Manish Mulimani
  • 17,535
  • 2
  • 41
  • 60
  • Thank you for your answer! I have now added the logcat output and edited my manifest (see above). However the RTF documents still can not be opened. – mjn Sep 24 '14 at 10:41
  • @mjn Did you add `android:scheme="content"` to manifest? I could not see that in your updated manifest. – Manish Mulimani Sep 24 '14 at 11:17
  • 1
    It works if I remove all other entries (for file, http and https scheme), they moved now to a second intent-filter element. Many thanks for your help! – mjn Sep 24 '14 at 11:32