Title: J2ME MIDP2.0
1J2ME MIDP2.0
2What is J2ME?
- Java 2 Micro Edition
- Specially cut down version of Java for mobile
devices, such as mobile phones, PDAs, Set Top
Boxes. - It combines a resource-constrained JVM (Java
Virtual Machine) and a set of Java APIs for
developing applications for mobile devices.
3What is J2ME?
- In CLDC, many features such as floating-point
support are missing, due to capabilities of the
device. - Extra features such as a GameAPI are now included
for mobile development. - Unlike windows, a java virtual machine comes
pre-installed on the phone.
4Why J2ME?
- Supported by over 1Billion handsets
- Device independent
5J2ME Development
- Sun Wireless Toolkit WTK
- Several IDEs Available
- NetBeans
- Eclipse
- Sun One
- Borland JBuilder
6Core and Optional Packages
- J2ME can be divided in 3 parts
7CLDC / CDC
- A profile is a superset of a configuration, of
which there are currently two - Connected Limited Device Configuration CLDC
- and
- Connected Device Configuration CDC
8MIDP
- It implements a profile such as MIDP for mobile
devices or foundation profile for embedded
devices like set-top boxes
9Optional Packages
- Several Optional Packages
- MMAPI
- PIM / File Connection
- WMAPI
- 3D API
- Bluetooth
10Fragmentation?
- Implementation of optional packages varies across
devices and manufacturers. - Nokia and Sony Ericsson provide consistent
approach - Other manufacturers vary
- See comparative table on blackboard
11Specifications
- Visit developer sites for device specifications
12Official Developer Sites
- Nokia www.forum.nokia.com
- Samsung http//developer.samsungmobile.com/eng/fro
nt_zone/bbs/bbs_main.jsp?p_menu_id1500 - Motorola http//developer.motorola.com/
- Sony Ericsson http//developer.sonyericsson.com/
- Microsoft http//www.microsoft.com/windowsmobile/d
evelopers/default.mspx - Blackberry http//www.blackberry.com/developers/in
dex.shtml - Siemens https//market.benqmobile.com/portal/main.
aspx?LangID0pid1 - Orange Partner
- http//www.orangepartner.com/site/enuk/home/p_hom
e.jsp
13MIDlets
- A Java program created for Mobile Devices (J2ME
application) - MIDlets will (should) run on any device that
implements J2ME MIDP - Like all Java programs, MIDlets are "compile
once, run anywhere - MIDlet .jar file
14MIDlet Reqs
- A MIDlet has to fulfill the following
requirements in order to run on a mobile phone - The main class needs to be a subclass of
javax.microedition.midlet.MIDlet - The MIDlet needs to be packed inside a .jar file
(e.g. by using the jar-tool) - The .jar file needs to be pre-verified by using a
preverifier.
15MIDlet Development Process
16MIDlet
- A MIDlet is a set of classes designed to be run
and controlled by the application management
software - The application must extend this class to allow
the AMS to control the MIDlet and to be able to
retrieve properties from the application
descriptor and notify and request state changes.
17MIDlet
- The methods of this class allow the AMS to
- Create
- Start
- Pause
- and destroy a MIDlet.
18MIDlet Life Cycle
19Basic MIDlet
- MainMidlet.java
- //classes needed for MIDlet execution
- import javax.microedition.midlet.
- import javax.microedition.lcdui.
- public class MainMidlet extends MIDlet
-
- public void startApp()
- //start application from here
- //set the display
-
-
- public void pauseApp()
- //pause application
-
-
- public void destroyApp(boolean unconditional)
- //stop application
20MIDlet Functions
- A MIDlet needs to have the following
- functions in order to compile
- startApp() this runs when the MIDlet is started
- pauseApp() this runs when the application is
paused e.g. incoming call - destroyApp() this runs when the MIDlet /
application is closed
21MIDlet States and Events
22MIDP GUI - Display Classes
- Different from J2SE (Java Standard Ed.)
- AWT and swing not implemented!
23High Level GUI
- Screens, forms, lists, choice, text fields
- all of these inherit
- javax.microedition.lcdui.Screen
- Easy to program pre-defined objects
- Not very flexible difficult to customize
objects - Unsuitable for multimedia applications although
it can be used for menus and settings
24GUI Display Classes
25Examples of High-Level GUI
26Low Level GUI
- Canvas
- Base class for writing applications that need to
handle low-level events and to issue graphics
calls for drawing to the display. - Full control over screen display.
- Ability to process events and key presses.
27Low Level GUI
- Canvas Game Canvas
- (A subclass of Canvas)
- provides the basis for a game user interface
- provides game-specific capabilities such as
- an off-screen graphics buffer
- the ability to query key status.
28/ MainMidlet.java / import
javax.microedition.midlet. import
javax.microedition.lcdui. public class
MyMidlet extends MIDlet //variable for
display private Display display //create
new MyGameCanvas private MyGameCanvas mgc
new MyGameCanvas() public void
startApp() // find current display
this.display Display.getDisplay( this )
// attach myGameCanvas to display
this.display.setCurrent(mgc) //start app
public void pauseApp() //pause app
public void destroyApp(boolean
unconditional) // Clear up resourses
notifyDestroyed() //destroyApp //end
class
/ MyGameCanvas.java / //import necessary
graphics classes import javax.microedition.lcdui.
game. import javax.microedition.lcdui.
public class MyGameCanvas extends GameCanvas
/ Creates a new instance of
MyGameCanvas / public MyGameCanvas()
super(true) //constructor public
void paint(Graphics g) /clear the screen
call this method anytime you wish to refresh the
gfx/ flushGraphics() //set the
colour to black in RGB values
g.setColor(0,0,0) / Draws the Hello
world string at x0, y0 location, the text is
aligned to the top left of the screen./
g.drawString("Hello World!!!",0,0,Graphics.T
OPGraphics.LEFT) //paint //class
29J2ME Online Resources
- Forum Nokia
- Orange
- Sony Ericsson
- Motorola
- Sun J2ME
- Several others available