Combee on Palm OS

Tuesday, 31 August 2004  10:05 AM

Many applications register with Exchange Manager to handle MIME types and URL schemes.  Normally, this is done as part of the application's startup code, and might also be done in reaction to a system reset or HotSync database change notification.  If your application is setup to perform this registration, you should also handle the sysAppLaunchCmdCardLaunch launch code and use that to affect your application's register/unregister behavior.

The reason is a bug in Palm OS; some of the functions that check to determine what application or library is registered for a given scheme will fail if there are any registrations for applications that aren't on the device.  Since ExgMgr registrations are stored as entries in the system preferences DB under the creator ID of the app, a normal application delete will also unregister it.  When an app is run off a VFS volume, its prefs are not deleted when it ends, which makes it easy to leave behind ExgMgr registrations that have no application to go with them.

Here's an example.  I've got an app called BenMemo that I've put on a SD card.  I put the card in my Palm OS device and select it from the launcher. The launcher copies it to memory and runs it.  As part of its normal startup, BenMemo registers with ExgMgr using ExgRegisterDatatype, saying it can handle the MIME type "text/plain".  When I switch back to the launcher, BenMemo is deleted from memory, but the preferences created by BenMemo are left intact.  I get a memo beamed to me from another device, ExgMgr tries to figure our who handles text/plain, it finds the BenMemo creator code, but when it doesn't find the program, it doesn't clean up correctly, leaving the prefs database open.  The next time an application tries to retrieve a preference, it can't open the prefs database, and the device has a fatal error.

The moral is that when your application is launched from a card, you should make sure that you unregister yourself when your application ends.  If you don't, you can easily trigger this problem.