Java Reference
In-Depth Information
Chapter 3. MIDP Programming
IN THIS CHAPTER
•
MIDlets
This chapter handles the life cycle and user interface of Mobile Information Device Profile (MIDP)
applications. First, the general design of MIDP applications will be discussed. Then, the high-level
user interface API will be explained. Finally, the low-level user interface API for free graphics
and games will be described.
MIDlets
All applications for the MID Profile must be derived from a special class,
MIDlet
. The
MIDlet
class manages the life cycle of the application. It is located in the package
javax.microedition.midlet
.
MIDlets can be compared to J2SE applets, except that their state is more independent from the
display state. A MIDlet can exist in four different states: loaded, active, paused, and destroyed.
Figure 3.1
gives an overview of the MIDlet lifecycle. When a MIDlet is loaded into the device and
the constructor is called, it is in the loaded state. This can happen at any time before the program
manager starts the application by calling the
startApp
() method. After
startApp()
is called,
the MIDlet is in the active state until the program manager calls
pauseApp()
or
destroyApp()
;
pauseApp
() pauses the MIDlet, and
desroyApp
() terminates the MIDlet. All
state change callback methods should terminate quickly, because the state is not changed
completely before the method returns.
Figure 3.1. The life cycle of a MIDlet.
In the
pauseApp()
method, applications should stop animations and release resources that are
not needed while the application is paused. This behavior avoids resource conflicts with the
Search WWH ::
Custom Search