Question

I want to have the default android browser be able to download files of a particular file extension, .xyz, for example.

Without installing Astro (or some other file manager), users will get the error "Cannot download. The content is not supported on this phone". Installing the Astro application allows the android browser to download any file to the sdcard.

How does it do that? I don't want users of my app to have to download Astro, but rather, just let the OS or browser know that it's okay to download files with the extension .xyz, because my app will handle them.

Was it helpful?

Solution

Add the appropriate entries to the manifest for you to respond to ACTION_VIEW Intents for that type of file. For example, this filter is for an activity that can view PDF files:

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:mimeType="application/pdf" />
        </intent-filter>

With an appropriate <data> element, you could literally watch for .xyz files, though I think it will be better if you can watch for a MIME type instead.

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