Search code examples
androidgoogle-chromeandroid-intentfile-type

File type registration fails for files shown in "Downloads" app


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"/>

Solution

    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