简体   繁体   中英

android download manager open file with my application

I have my android app, that downloads a file via the DownloadService. This file is in special file format, that only can be used in my app - it has the suffix *.foobar.

I start the download this way:

DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setDestinationInExternalPublicDir("/", "aaaa.foobar");

// get download service and enqueue file
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);

Download works fine, but when I tap on the notification "download finished", I want that my activity will be opened. What I get is the toast "File can not be opened".

In my Manifest I have a intent-filter for the .foobar file suffix.

    <intent-filter android:label="@string/app_name">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="file" />
        <data android:mimeType="*/*" />
        <data android:pathPattern=".*\\.foobar" />
        <data android:host="*" />
    </intent-filter>

Am I missing something?

finally found the solution!

I had to remove the path pattern line

                <data android:pathPattern=".*\\.foobar" />

and change the schema to content. So the complete intent filter is:

<intent-filter android:label="@string/app_name">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="content" />
                <data android:mimeType="application/wcmap" />
                <data android:host="*" />
            </intent-filter>

I think you will find the answer to this answer . Most likely you have a problem in the treatment of Activiti or slightly incorrect description of intent.

Try adding a priority .

android:priority="integer"

Also you should look:

Good luck. Sorry that can not help more. Too much text for a comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM