views:

129

answers:

2

In Android, I am trying to make it so that the user downloads a font from the browser, and I am able to view the font when downloaded. After multiple issues, I still have one lingering one: Registering the filetype with the browser.

When trying to download with the Emulator (2.1-u1), I get "Cannot download. The content is not supported on this phone". Okay, so maybe its my manifest file. Updated with this:

    <activity android:name=".MainActivity" android:label="MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
            <catagory android:name="android.intent.category.BROWSABLE"/>
            <data android:scheme="http"/>
            <data android:scheme="https"/>
            <data android:scheme="ftp"/>
            <data android:host="*"/>
            <data android:mimeType="*/*"/>
            <data android:pathPattern=".*zip"/>
        </intent-filter>
    </activity>

Went back to the browser, and fails again. Restart the Emulator, still fails.

Note that I got this format from posts here.

Any suggestions on what to do?

A: 

Registering for a MIME type of */* and a host of * is rather impolite. You are attempting to handle every ZIP file from every Web site, whether it is a font or not.

Try an action of VIEW instead of MAIN.

CommonsWare
I choose those wildcards because I don't want to whitelist websites, and I have no idea what MIME types I'm going to be handling. What would be better if I could set permissions programatically instead of statically, since I'm sure the user will download zip files for other reasons. Is there a way to do it in Java and not XML?
TheLQ
@Lord.Quackstar: "I choose those wildcards because I don't want to whitelist websites, and I have no idea what MIME types I'm going to be handling" Reconsider your app, then. Perhaps you should be writing a general-purpose ZIP utility which has whatever font functionality you're implementing as a feature. You're going to have to do *something* to justify your app claiming to handle all ZIP files. "Is there a way to do it in Java and not XML?" No, sorry.
CommonsWare
The issue that I'm having is that in my app people can go to the browser, download fonts (in this case a zip file), and apply them to the app. I'm setting it for ZIP because most fonts are inside of ZIP files, and its easier on the user if they don't have to manually extract the file. Doesn't the browser give an option to open with a specific program if multiple one's claim to be able to open zip files?
TheLQ
And BTW, failed with VIEW action. Still getting error
TheLQ
"Doesn't the browser give an option to open with a specific program if multiple one's claim to be able to open zip files?" Yes, but that is for general-purpose functionality. Why should a user viewing a ZIP attachment in their email program have to skip past your "hey, it might be a font!" option?
CommonsWare
Because it might be. I don't want to tell the user "You must do complicated steps this, this and this in order, and oh yea, you can only use the browser and file manager X". Its a simple font in a zip file. If nothing else can open a Zip file on the phone, then my program opens and I ask the user something like "Do you wish to open this as a font?". That should be extreamly easy
TheLQ
A: 
<catagory android:name="android.intent.category.BROWSABLE"/>

The first word on that line, "catagory", should be "category". Maybe that typo is the cause of the problem.

Graham Borland