Question

I've seen this question asked 100+ times but none of the answers are working for me. I want my app to handle all files with ics or vcs extensions, *no matter where they come from. *Except, I don't want to have to download them myself if they come from http/https, I just want the browser to at least let the user save them and then open with my app. Currently the browser says "content not supported on this phone".

Here is what I currently have, but I've been trying everything:

        <intent-filter >
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:host="*" />
            <date android:mimeType="text/calendar" />
            <data android:scheme="https" />
        </intent-filter>

With the above, when I click an https link, one that comes from my server and I know my server is sending the text/calendar mime-type, the droid asks what app they want to use to open the link. The list has my app or the browser. If I select my app, it runs my activity and gives me the Uri. I want the browser to download the file though, I don't want to have to download it myself... same way other file types work, images, pdfs, etc. If I select the browser, it starts the download but then stops with a "content not supported on this phone" error.

I also tried this:

        <intent-filter >
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:host="*" />
            <data android:scheme="file" />
            <data android:pathPattern=".*\\.ics" />
        </intent-filter>

Also tried with the scheme set to "content", and lots of other variations I found on SO and other places.

Was it helpful?

Solution

You should consider that the browsers are implementing this download behavior for binary files and you can not change it by a intent-filter.

Other applications like pdf viewer declare an intent-filter identical to your second approach (except for the file-extension).

Therefore I would recommend to just download the file yourself. As it just requires a few lines of code this should not be a big problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top