Skip to Main Content
Wireless Java
book

Wireless Java

by Qusay H. Mahmoud
January 2002
Intermediate to advanced content levelIntermediate to advanced
264 pages
8h 3m
English
O'Reilly Media, Inc.
Content preview from Wireless Java

Chapter 4. Working with MIDlets

MIDlets are very simple to implement. All MIDlets must extend the javax.microedition.midlet.MIDlet abstract class and implement certain methods in that class. The MIDlet abstract class provides the basic functionality required in all MIDlets. A MIDlet runs in a controlled environment and therefore must implement certain methods that allow the application manager (which installs and runs the MIDlet) to control the behavior of the MIDlet. These methods are known as life cycle methods, since they reflect various states in which a MIDlet can be.

You’ll recall from the previous chapter that a MIDlet can be in one of three states: paused, active, or destroyed. The state chart in Figure 4-1 shows the possible state transitions of a MIDlet, this time with the addition of the methods that the Java Manager will call inside the MIDlet code during those transitions.

MIDlet state transitions

Figure 4-1. MIDlet state transitions

Here, the javax.microedition.midlet.MIDlet abstract class defines three life cycle methods that are called during the state transitions: pauseApp(), startApp(), and destroyApp(). These three methods were present in the example we developed in Chapter 1. The responsibilities for these three life cycle methods are as follows.

public void startApp( )

This method indicates that the MIDlet is moving from a paused state to an active state. Here, the MIDlet will typically ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Wireless J2ME™ Platform Programming

Wireless J2ME™ Platform Programming

Vartan Piroumian
Java Power Tools

Java Power Tools

John Ferguson Smart

Publisher Resources

ISBN: 0596002432Supplemental ContentCatalog PageErrata