RIM’s PlayBook development guide is wrong

I recently found some issues with my apps on the BlackBerry PlayBook. These issues were a direct result of following RIM’s BlackBerry Tablet development guide. They need to fix this and stop making suggestions that simply do not work.

The article wisely recommends that you make sure that the application’s state is saved when it is deactivated and pushed to the background, but recommends a technique that is inconsistent at best. They are recommending that you save data by listening for Event.DEACTIVATE which detects when another application receives focus. However this event is never fired when the application exits (unless you run in Paused mode like the simulators used to). Assuming that you could use this approach to save data upon exiting is at the root of a lot of the problems in the early PlayBook applications.

Instead you can actually detect the application closing by using NativeApplication.nativeApplication.addEventListener(Event.EXITING,saveData) to listen for an exiting event, and saving data then. Until RIM’s development guide on the life cycle of PlayBook applications mentions this, it will just be wrong.