问题
I'm trying to make the android browser download a file of a specific type '.xxx’ say, so that I can then set an app to be associated with it.
I've successfully done the association part, in that I've made it so that clicking on a file of the right type in an explorer app loads the appropriate app. I expected this to carry over to the browser so that if I attempted to download a file type .xxx then it would open the app.
This doesn’t happen, all that happens is that the text contained in the file is displayed in the browser. I've set up a mime type link for this in astro (application/xxxx) but this has made no difference either. It must be possible to do what I want because If I click on a pdf file for instance the browser downloads it and gives me the option to open a pdf reader.
回答1:
You need to add an <intent-filter>
tag within a <receiver>
tag in your Application Manifest.
How this works is the following:
Android broadcasts an intent
The system searches a list of applications capable of receiving that intent
The system queries the user to select an application to handle that intent
The user selects an application, or is defaulted to a pre-specified application
The application opens
Take a look at the receiver element docs to see more details about how to implement this.
Holler if you need more help.
Thanks
回答2:
Android applications define which 'file types' they support in their respective manifest files. If your app isn't loading when the browser calls it then maybe there is something missing in your manifest? What happens in the simulator?
http://developer.android.com/guide/topics/manifest/manifest-intro.html
回答3:
All mime you can you for Android : link
来源:https://stackoverflow.com/questions/7968591/android-download-file-directly-from-browser