Search This Blog

Wednesday, 5 July 2023

MIDlet Programming

0 comments

Programming a MIDlet is similar to creating a J2SE application in that you define a class and related methods.

MIDlet Class:

  • A MIDlet is a class that extends the MIDlet class and is the interface between application statements and the run-time environment, which is controlled by the application manager (figure 3-3). 
  • A MIDlet class must contain three abstract methods that are called by the application manager to manage the life cycle of the MIDlet. These abstract methods are startApp(), pauseApp(), and destroyApp(). 

  • The startApp() method is called by the application manager when the MIDlet is started and contains statements that are executed each time the application begins execution. 
  • The pauseApp() method is called before the application manager temporarily stops the MIDlet. The application manager restarts the MIDlet by recalling the startApp() method. 
  • The destroyApp() method is called prior to the termination of the MIDlet by the application manager.

 

  • Both the startApp() and pauseApp() methods are public and have no return value nor parameter list. 
  • The destroyApp() method is also a public method without a return value. 

However, the destroyApp() method has a boolean parameter that is set to true if the termination of the MIDlet is unconditional, and false if the MIDlet can throw a MIDletStateChangeException telling the application manager that the MIDlet does not want to be destroyed just yet.

Mobile Information Device Profile (MIDP):

At the center of every MIDlet are the MIDP API classes used by the MIDlet to interact with the user and handle data management. 

User Interface API:

  • User interactions are managed by user interface MIDP API classes. These APIs enable a developer to display screens of data and prompt the user to respond with an appropriate command. 
  • The command causes the MIDlet to execute one of three routines: perform a computation, make a network request, or display another screen.

 Data Handling API:

The data-handling MIDP API classes enable the developer to perform four kinds of data routines: 

  1. Write and read persistent data
  2. Store data in data types
  3. Receive data from and send data to a network and
  4. Interact with the small computing device’s input/output features.

Runtime Environment

  • A MIDlet is a J2ME application designed to operate on an MIDP (CDLC) small computing device.
  • A MIDlet is defined with at least a single class that is derived from the javax .microedition.midlet.MIDlet abstract class.
  • Developers commonly bundle related MIDlets into a MIDlet suite, which is contained within the same package and implemented simultaneously on a small computing device.
  • All MIDlets within a MIDlet suite are considered a group and must be installed and uninstalled as a group (Figure 3-2).

  • Members of a MIDlet suite share resources of the host environment and share the same instances of Java classes and run within the same JVM.
  • A key benefit of the relationship among MIDlet suite members is that they share the same data, including data in persistent storage such as user preferences.  Data cannot be shared between MIDlets that are not from the same MIDlet suite.
  • A MIDlet suite is installed, executed, and removed by the application manager running on the device.  Once a MIDlet suite is installed, each member of the MIDlet suite is given access to classes of the JVM and CLDC by the application manager.

Device Data:

Small computing devices don’t have the resources necessary to run an onboard database management system (DBMS).  Therefore, a MIDlet must read and write persistent data without the advantage of a DBMS or file system.
  • A MIDlet can use an MIDP class—RecordStore—and two MIDP interfaces—
    RecordComparator and RecordFilter—to write and read persistent data. 
  • Persistent data is read from a RecordStore by using either the RecordComparator interface or the RecordFilter interface. 
  • A RecordStore class contains methods used to write and read persistent data in the form of a record.
Here is the Lab Manual for experimenting MAD using J2ME.

Leave a Reply