views:

18

answers:

1

I have an Android application which handles a particular type of file. It registers intent filters for both the MIME type and the filename pattern. This all works fine from file managers; I select a file, I get prompted with a list of actions applicable to the file, my application is on the list, I select it and it works.

However, this doesn't work when I beam a file to the device via Bluetooth. The file gets received and is correctly downloaded, but selecting the file from the transfer page does nothing (although I can still use a file manager to find the downloaded file in /sdcard/downloads/bluetooth and run it from there). The log contains:

V/BluetoothOppUtility(  565): Get data from db:/mnt/sdcard/downloads/bluetooth/foo.appnull00:11:22:33:44:55
E/BluetoothOppUtility(  565): ERROR: Para fileName ==null, or mimetype == null

(The name of the file here is foo.app.)

It looks like it's deciding that the file has no MIME type and is giving up, rather than broadcasting an intent asking for a filename-based match.

This is on Froyo on an HTC Desire, and I know that HTC have been tinkering with the Bluetooth stack (as stock Android doesn't allow arbitrary files to be beamed to the device). Does anyone know how I can make this work? Beaming .jpg and .png files works fine...

A: 

Investigation reveals that the Bluetooth stack, if it doesn't receive a MIME type from the sender, determines the MIME type by using the android.webkit.MimeTypeMap class. This class has a hard-coded table of extensions and MIME types. This means that it's not possible to register additional extensions without sending patches to Google and waiting for the next release.

David Given