A MIDlet
is a Java class that extends the javax.microedition.midlet.MIDlet
abstract class. It implements the startApp()
, pauseApp()
, and destroyApp()
methods, which you can think of as being similar to J2SE's start()
, stop()
, and destroy()
methods in the java.applet.Applet
class.
In addition to the primary MIDlet
class that extends javax.microedition.midlet.MIDlet
, an MIDP application usually includes other classes, which can be packaged as jar files along with their resources -- this is known as a MIDlet suite. The various MIDlets in a MIDlet suite can share the resources of the jar file, although MIDlets from different suites cannot directly interact.
A MIDlet exists in one of three possible states during the application life cycle -- active, paused, or destroyed. Active state, as the name implies, means the MIDlet is running. This state begins when the startApp
method is called. In a paused state, all resources the MIDlet is holding are released, but it is prepared to be activated again. The notifyPaused
method invokes the paused state. In the destroyed state, a MIDlet has permanently shut itself down, releasing all resources, and is awaiting the garbage collector. It is invoked with the notifyDestroyed
method.
In the next couple of panels, we'll look at a simple HelloWorld MIDlet.