Application Lifecycle: DetailsApplication StartupThe lifecycle begins when the nlpd calls the main routine in an application library. An argv argument tells the application if it is to be the main window, or run in the background, or whether it was started to handle something specific. You can see the argv strings in the source at hiker/main/dist/include/hiker/appmgr.h or in the doxygen documentation (once you build it). Here are some of the strings, and their effects on the application. #define ALP_APP_PRIMARY "alpprimary" The most common launch argument is ALP_APP_PRIMARY. An application is typically launched with ALP_APP_PRIMARY, and will continue execution until a new primary application is launched. For the most simple applications, nothing beyond basic GTK (or other GUI toolkit) infrastructure may be needed. More complex applications, however, need some extra work beyond the basic GTK code, and this is where the other launch arguments come into play. Application Execution Applications generally run like any GUI application. They use a toolkit like GTK to Application Re-executionThe major departure from the usual desktop environment is that we only permit running a single instance of any given application. If a running application is launched again, it keeps running but the new launch arguments are delivered to it and the application is expected to update its state accordingly. Applications receive new launch arguments through a callback that is termed a "relaunch handler", which is put in place by calling alp_app_set_relaunch_handler(). This handler will then be called later by the appserver clientside library in response to a launch request for the already-running application. It gives the application the opportunity to examine the new launch arguments, and update its state. This might mean handling an exchange request, showing or hiding UI, etc. In other words, if the application is already running, the framework can tell it of a new task that must be done. And if an application is not running, the framework can start the application to ask it to handle a particular task. In this case, the application generally runs in the background with no GUI displayed. Applications which might be relaunched include those that support/require both primary and background execution, register for system notifications, or register with Exchange Manager to handle some particular content types. It's worth noting that unless the application goes out of its way to use Framework-specific facilities (by specifying an ALP_APP_BACKGROUND_* property in its Manifest.xml file, registering for notifications or alarms, registering with the ExchangeMgr, etc), then it will probably never be launched while it is already running, and thus there is no need for it to register a relaunch handler. This provides an easier transition for developers or software porters familiar with the GUI toolkit but not Hiker. The app server will shut down and restart an app, if it gets a launch request for an app that is already running but which does not have a relaunch handler. Application Shutdown We maintain the traditional ACCESS Garnet OS model of having the system tell the application
when to exit. While an application may exit at any time of its own accord, it should also
be sure to always honor an exit request from the appserver. Exit handlers are always executed in order, starting with the most recently added. Back to "Application Lifecycle " |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright © 2007, The Hiker Project. All rights reserved. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||