Slide 6.13: Palm OS programming concepts
  Slide 6.15: Event loop
  Home


Application Startup and Stop


A Palm OS application launches when the user requests it. Palm OS applications do not have an Exit command; instead they exit when a user requests another application.

1. Launch Codes and Launching an Application
An application launches when it receives a launch code. For example, an application typically launches when a user presses one of the buttons on the device or selects an application icon from the application launcher screen. When this happens, the system generates the launch code sysAppLaunchCmdNormalLaunch, which tells the application to perform a full launch and display its user interface.

2. Responding to Launch Codes
The application should respond to launch codes in a function named PilotMain, which is the entry point for all applications. When an application receives a launch code, it must first check whether it can handle this particular code. For example, only applications that have text data should respond to a launch code requesting a string search. If an application can not handle a launch code, it exits without failure. Otherwise, it performs the action immediately and returns.

3. Responding to Other Launch Codes
If an application receives a launch code other than sysAppLaunchCmdNormalLaunch, it decides if it should respond to that launch code. If it responds to the launch code, it does so by implementing a launch code handler, which is invoked from its PilotMain function.

5. Stopping an Application
An application shuts itself down when it receives the event appStopEvent. The application must detect this event and terminate. When an application stops, it is given an opportunity to perform cleanup activities including closing databases and saving state information.