0% found this document useful (0 votes)
8 views11 pages

Topic 2 - Slide Notes

The document discusses MIDlets and MIDlet programming, covering historical developments, lifecycle, creation process, layout, and examples. It outlines the states a MIDlet goes through, including Paused and Active states, and details the steps for creating a MIDlet from design to deployment. An example of a simple MIDlet is provided to illustrate the concepts discussed.

Uploaded by

Blueprint Mih
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views11 pages

Topic 2 - Slide Notes

The document discusses MIDlets and MIDlet programming, covering historical developments, lifecycle, creation process, layout, and examples. It outlines the states a MIDlet goes through, including Paused and Active states, and details the steps for creating a MIDlet from design to deployment. An example of a simple MIDlet is provided to illustrate the concepts discussed.

Uploaded by

Blueprint Mih
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Page 1 of 11 Dr.

Mwakondo PhD (Computer Science) UoN

Topic 2:MIDlets and MIDlet programming


-Historical developments
-MIDlet lifecycle
-MIDlet creation process
-MIDlet layout
-MIDlet Example
-Exercise
Page 2 of 11 Dr. Mwakondo PhD (Computer Science) UoN

2.1 Historical Developments


• applications
– java programs that can run on any platform
• applets
– small java programs downloadable over the
browser
• servlets
– java programs that run in the network server
• MIDlets
– java programs that run in small computing
devices with limited memory, processor
Page 3 of 11 Dr. Mwakondo PhD (Computer Science) UoN

2.2 MIDlet lifecycle


Page 4 of 11 Dr. Mwakondo PhD (Computer Science) UoN

Contd...
• A MIDlet goes through the following states:
1. When the MIDlet is about to be run, an instance is
created by the MIDlet’s constructor, and the MIDlet is
in the Paused state.
2. Next, the MIDlet enters the Active state after the
application manager calls startApp().
3. While the MIDlet is Active, the application manager
can suspend its execution by calling pauseApp(). This
puts the MIDlet back in the Paused state. A MIDlet can
place itself in Paused state by calling notifyPaused().
4. While the MIDlet is in the Paused state, the
application manager can call startApp() to put it back
into the Active state.
Page 5 of 11 Dr. Mwakondo PhD (Computer Science) UoN

5. The application manager can terminate the execution


of the MIDlet by calling destroyApp(), at which point
the MIDlet is destroyed and patiently awaits garbage
collection. A MIDlet can destroy itself by calling
notifyDestroyed().
Page 6 of 11 Dr. Mwakondo PhD (Computer Science) UoN

2.3 Process of MIDlet creation


• steps:
1.Design
–specify the display/screen layout, process logic,
output and input formats
2.Code
–translate design into executable instructions
following a particular programming language syntax
–Java is object oriented and in J2ME platform at
least two things must be done:
– each MIDlet class must extend the abstract
MIDlet class
– each MIDlet class must override at least three
methods of the abstract class:
 startApp()
Page 7 of 11 Dr. Mwakondo PhD (Computer Science) UoN

 pauseApp()
 destroyApp(Boolean unconditional)
3.Compile
–convert the source code into object code or bytecode
in java
4.Preverify
–check and ensure that the class file is structurally
and conceptually correct as per the JVM
specifications
5.Package
–prepare the MIDlet for testing and deployment
where the manifest and jar files are created
6.Test
Page 8 of 11 Dr. Mwakondo PhD (Computer Science) UoN

–test the MIDlet by running it in an emulator device


that mimics functionality of the real device on your
computer
7.Deploy
–install the MIDlet in the target mobile device for
operations
Page 9 of 11 Dr. Mwakondo PhD (Computer Science) UoN

2.4 MIDlet layout


Import statements;
Public class name extends MIDlet{
/* Data members*/
variable declarations;
/* constructor*/
Public name(){
Instructions;
}
/* startApp()*/
Public void startApp(){
Instructions;
}
/* pauseApp()*/
Public void pauseApp(){
Instructions;
}
/*destroyApp()*/
Public void destroyApp(boolean unconditional){
Instructions;
}
}
Page 10 of 11 Dr. Mwakondo PhD (Computer Science) UoN

2.5 MIDlet Example


Import java.util.Date;
Import javax.microedition.lcdui.Alerts;
Import javax.microdetion.lcdui.Displayable;
Import javax.microedition.midlet.MIDlet;

Public class DateTimeApp extends MIDlet{


Alert timeAlert;

Public DateTimeApp()
timeAlert=new Alert(“Alert”);
timeAlert.setString(new Date().toString());
}
Public void startApp(){
Display.getDisplay(this).setCurrent(timeAlert);
}
Public void pausedApp(){
}
Public void destroyApp(Boolean unconditional){
}
}
Page 11 of 11 Dr. Mwakondo PhD (Computer Science) UoN

You might also like