Introduction to J2ME: Programming the Small Devices

Mobile Applications
‡ Developing wireless applications using WAP technologies is similar to developing web pages with a markup language because it is browser based. ‡ Another approach to developing wireless applications is to use the Mobile Information Device Profile (MIDP).

2

Mobile Devices Constraints
‡ Memory Restricted
± Heap memory ± Record Management System

‡ Memory Fragmentation ‡ Display & Colour
± 208x320 , ± 176x208 with 128 colours

3

Mobile Device Constraints ‡ Different Phone Interfaces & Different Features 4 .

Programming for Mobiles ‡ Languages Used ± Java ± C++ ± C# .NET ± Python ‡ Technologies Used ± Java ME ± BREW 5 .

6 .Java for mobile devices (Java ME) ‡ Java is served in 3 Editions ± Java EE Enterprise Edition for Enterprise / Server Class of Applications (formerly J2EE) ± Java SE Standard Edition for desktop class of Applications (formerly J2SE) ± Java ME Micro Edition for small devices (formerly J2ME) ‡ Each of the Edition is meant to manage available resources like Memory. Display power and UI suiting the application. CPU.

Java ME in the Java Space 7 .

virtual machines and APIs. ‡ Java ME uses scaled down subsets of Java SE components. ‡ It defines APIs that are specifically targeted at consumer mobile and embedded devices. which was developed for small devices like mobile phones and set-top boxes.Enter Java ME ‡ Most mobile applications use the Java Micro Edition (Java ME) platform. 8 .

‡ The AWT is designed to work with a pointing device such as a mouse. however many handheld devices have only a keypad for user input.Why not AWT? ‡ The AWT is designed for desktop computers and not optimized for small devices. The limited CPU and memory of handheld devices cannot handle this behavior. 9 . ‡ While the AWT has a rich feature set for managing windows. The window and layout managers within the AWT are not required for handheld devices due to paucity of resources. ‡ AWT-based applications use event objects.

and ± an optional package is a set of technologyspecific APIs. ± a profile is a set of APIs that support a narrower range of devices. 10 .Java ME elements ‡ The Java ME technology is based on three elements ± a configuration provides the most basic set of libraries and virtual machine capabilities for a broad range of devices.

‡ The two virtual machines are ± JVM (Java Virtual Machine) and ± KVM (K Virtual Machine). Limited Device Configuration). 11 . ‡ CDC and JVM are aimed at desktops and higherend mobile devices ‡ CLDC and KVM are for limited and small devices.Java ME ‡ The micro edition consists of two so-called configurations and two virtual machines. ‡ The two configurations are ± CDC (Connected Device Configuration) and ± CLDC (Connected.

Layered Structure of Java ME ‡ Java ME forms a layered structure CDC Based Personal Profile CDC JVM CLDC Based MID Profile CLDC KVM 12 Device Hardware .

‡ Identifies the low level features and low level facilities to use the resources of the device ‡ CDC and CDLC are configurations 13 . targeted at a specific class of devices. ‡ A configuration. The set of APIs is customarily a subset of the Java SE APIs. ‡ The virtual machine is either a full Java Virtual Machine (as described in the specification) or some subset of the full JVM. for example.What is a Configuration? ‡ A configuration is a specification that describes a virtual machine and some set of APIs. might be designed for devices that have less than 512 KB of memory and an intermittent network connection.

CDC and CDLC ‡ Connected Device Configuration (CDC) is for devices with much greater memory. ± MIDP is based on CDLC. processing power and network connectivity such as smart phones. ‡ Connected Limited Device Configuration (CLDC) is for devices with less memory and processing power than CDC-based devices. and embedded servers and devices. set-top boxes. and together they provide the standard Java runtime environment and a rich set of APIs for most popular mobile devices 14 .

version 1.CLDC ‡ CLDC is a specification and it is positioned on top of the KVM. ‡ It specifies APIs for devices with less than 512 KB of RAM for the Java system and a limited and intermittent network connection. 15 . ‡ The APIs on this level define the core of the J2ME language. ‡ There are currently two versions of CLDC.1. and are rarely used by programmers.0 and 1. ‡ The specification of the KVM is included in the CLDC.

‡ connectivity to some kind of network. ‡ low power consumption. 16 . ‡ a 16-bit or 32-bit processor. often operating with battery power. often with a wireless connection and with limited (often 9600 bps or less) bandwidth.CLDC Characteristics ‡ CLDC provides the lowest common denominator for small and resource-constrained devices characterized as follows: ‡ 160 kB to 512 kB of totally memory budget available for the Java platform.

0 : does not support floating point numbers.1 : supports floating point data type out from the box.CLDC Versions ‡ CLDC 1. operation and datatype/class. making floating point operation much more faster and more accurate than using 3rd party floating point number class implementation 17 . which cannot be accurate for large numbers ‡ CLDC 1. All floating point operation are done through 3rd party class implementation.

18 . ‡ Profiles usually include APIs for application life cycle. it does not by itself specify enough detail to enable you to build complete applications. ‡ A profile builds on a configuration but adds more specific APIs to make a complete environment for building applications. and persistent storage. ± While a configuration describes a JVM and a basic set of APIs.What is a Profile? ‡ A high level abstraction of all resources for a class of devices which can be used by an application. like mobiles. ‡ MIDP is a profile for small footprint devices. user interface.

‡ One example of an optional package is the Bluetooth API . 19 .Optional Package ‡ An optional package provides functionality that may not be associated with a specific configuration or profile. which provides a standardized API for using Bluetooth networking. This optional package could be implemented alongside virtually any combination of configurations and profiles.

1 ‡ JSR 129 PBP Personal Basis Profile ‡ JSR 217 PBP 1.0 JSR 75 PDAP PDA Profile ‡ ‡ JSR 46 FP Foundation Profile ‡ JSR 219 FP 1.1 ‡ JSR 36 CDC Connected Device Configuration ‡ JSR 218 CDC 1. Limited Device Configuration JSR 139 CLDC 1.0 Mobile Information Device Profile 2.1 JSR 62 PP Personal Profile ‡ ‡ JSR 215 PP 1.1 Foundation Profile 1.1 Connected.0 Connected. Limited Device ‡ Configuration 1.1 Connected Device Configuration 1.1 Profiles JSR 37 MIDP 1.Configurations. Packages Configurations ‡ JSR 30 CLDC 1.1 Personal Basis Profile 1.1 Personal Profile 1. Profiles.1 ‡ JSR 195 IMP Information Module Profile ‡ JSR 228 IMP-NG Information Module Profile Next Generation Optional Packages ‡ JSR 75 PDA Optional Packages for the J2ME Platform ‡ JSR 82 Java APIs for Bluetooth ‡ JSR 120 Wireless Messaging API JSR 205 Wireless Messaging API 2.0 Mobile Information Device ‡ Profile ‡ JSR 118 MIDP 2.0 ‡ ‡ JSR 135 Mobile Media API ‡ JSR 164 JAIN SIMPLE Presence ‡ JSR 165 JAIN SIMPLE Instant Messaging ‡ JSR 172 J2ME Web Services JSR 177 Security and Trust Services API for J2ME ‡ ‡ JSR 179 Location API for J2ME ‡ JSR 180 SIPSIP API for J2ME ‡ JSR 184 Mobile 3D Graphics API for J2ME ‡ JSR 186 JAIN Presence JSR 187 JAIN Instant Messaging ‡ ‡ JSR 190 Event Tracking API for J2ME ‡ JSR 209 Advanced Graphics and User Interface ‡ JSR 211 Content Handling API ‡ JSR 213 Micro WSCI Framework for J2ME JSR 214 Micro BPSS for J2ME Devices ‡ ‡ JSR 226 Scalable 2D Vector Graphics API ‡ JSR 229 Payment API ‡ JSR 230 Data Sync API ‡ JSR 232 Mobile Operational Management ‡ JSR 234 Advanced Multimedia Supplements JSR 238 Mobile Internationalization API ‡ ‡ JSR 239 Java Bindings for OpenGL ES ‡ JSR 246 Device Management API ‡ JSR 253 Mobile Telephony API (MTA) 20 .

networking. then deploy them quickly to a wide variety of mobile information devices. 21 . and is supported by leading integrated development environments (IDEs). ‡ It is deployed globally on millions of phones and PDAs. ‡ MIDP has been widely adopted as the platform of choice for mobile applications. and persistent storage. ‡ Developers using MIDP can write applications once.MIDP ‡ The Mobile Information Device Profile (MIDP) adds APIs for application life cycle. user interface.

touch) ± Screen size of at least 96x54 pixels 22 .MIDP Characteristics ‡ MIDP adds an additional layer on the top of the CLDC providing APIs for a specific class of devices: ± 128KB of non-volatile memory for the MIDP implementation ± 32KB of volatile memory for the runtime heap ± 8KB of non-volatile memory for persistent data ± Input capacity (screen. keyboard.

CLDC Wireless Platform ‡ Combines CLDC with the Mobile Information Device Profile (MIDP) to provide a complete Java application environment for mobile phones and other devices with similar capabilities. the actual application then resides and uses the different available APIs in the profile 23 . ‡ With the configuration and profiles.

and works in combination with today's leading IDEs.x which includes the mobility pack ) 24 . ‡ Java ME SDK 3. or 6. ‡ Netbeans Mobility ( 5.Development Toolkits ‡ The Sun Java Wireless Toolkit provides complete development support for developing MIDP applications. Mobile Edition is a Javatechnology IDE for developing applications that can be deployed to Java technology-enabled mobile devices.0 with Mobility pack.0 combines both the above.. ‡ Sun ONE Studio.

Sun Java Wireless Toolkit CDLC ‡ The Sun Java Wireless Toolkit CLDC (formerly known as Java 2 Platform. ‡ Designed to run on cell phones. Micro Edition (J2ME) Wireless Toolkit) is a toolbox for developing wireless applications that are based on Java ME platform's Connected Limited Device Configuration (CLDC) and Mobile Information Device Profile (MIDP). performance optimization and tuning features. documentation. and examples 25 . mainstream personal digital assistants. and other small mobile devices. ‡ Toolkit includes the emulation environments.

26 . extra buttons such as arrow keys. ‡ The GUI is optimized for the small display size. ‡ MIDP provides intuitive navigation and data entry by taking full advantage of phone keypads. varied input methods. touch screens. and other native features of modern mobile devices. and small QWERTY keyboards.MIDP Features. can operate in both networked and unconnected modes. and can store and manage persistent local data securely.Rich UI capabilities ‡ MIDP applications provide the foundation for highly graphical and intuitive applications. ‡ MIDP applications are installed and run locally.

and serial port. including HTTP. datagrams. ‡ MIDP also supports the Short Message Service and Cell Broadcast Service capabilities of GSM and CDMA networks. HTTPS. 27 . through the Wireless Messaging API (WMA) optional package.MIDP Features-Extensive Connectivity ‡ MIDP enables developers to exploit the native data network and messaging capabilities of mobile information devices. server sockets. ‡ It supports leading connectivity standards. sockets.

Multimedia & Game Functionality Support ‡ MIDP is ideal for building portable games and multimedia applications. ‡ A game API adds game-specific functionality. 28 . such as sprites and tiled layers. which take advantage of devices' native graphics capabilities. ‡ In addition. giving developers greater control of graphics and input. and WAV files. ‡ A low-level UI API complements the high-level UI API. tone sequences. developers can use the Mobile Media API (MMAPI) optional package to add video and other rich multimedia content to MIDP applications. ‡ Built-in audio provides support for tones.MIDP Features.

0 MIDP-2.0 MIDP-1.0 CLDC-1.0 MIDP-1.0 MIDP-1.0 MIDP-2.1 29 .0 MIDP-2.1 CLDC-1.0 MIDP-2.1 CLDC-1.0 MIDP-2.0 CLDC-1.1 CLDC-1.0 CLDC-1.0 MIDP-2.0 MIDP-2.0 MIDP-2.1 CLDC-1.0 CLDC-1.1 CLDC-1.1 CLDC-1.0 MIDP-2.0 CLDC-1.0 MIDP-2.1 CLDC-1.0 MIDP-2.Mobile Devices : A list Brand BlackBerry BlackBerry BlackBerry LG LG LG LG LG LG Motorola Motorola Motorola Motorola Motorola Motorola Nokia Nokia Nokia Nokia Nokia Nokia 6710 8100 9100 B2000 B2100 C1300i CU515 G5500 KF310 C385 C550 E1 ROKR K3 MOTORAZRmaxxV3 MOTOROKR E6 3100 3110c 3200 5300 7210 E60-1 Model MIDP-2.1 CLDC-1.0 CLDC-1.0 CLDC-1.1 CLDC-1.0 MIDP-2.0 MIDP-1.0 Profiles Configuration CLDC-1.0 MIDP-2.1 CLDC-1.1 CLDC-1.0 MIDP-2.0 MIDP-2.0 MIDP-1.1 CLDC-1.0 CLDC-1.

0 CLDC-1.1 CLDC-1.0 MIDP-2.0 MIDP-2.0 MIDP-1.0 MIDP-2.0 CLDC-1.0 MIDP-2.0 Profiles Configuration CLDC-1.1 CLDC-1.1 CLDC-1.1 CLDC-1.0 MIDP-1.1 CLDC-1.0 MIDP-2.0 CLDC-1.0 CLDC-1.1 CLDC-1.0 MIDP-2.1 CLDC-1.0 MIDP-1.Mobile Devices List contd: Brand Nokia Nokia Nokia Nokia Panasonic Panasonic Panasonic Sagem Sagem Samsung Samsung Samsung Siemens Siemens Siemens SonyEricsson SonyEricsson N-Gage N70 N91 N93-1 X200 X60 X500 my300X my501X GT-S7330 SGH-A801 SGH-D510 AF51 C75 M81 Z500i W710i Model MIDP-1.0 MIDP-2.1 30 .0 MIDP-2.0 MIDP-2.1 CLDC-1.0 MIDP-2.0 CLDC-1.1 CLDC-1.0 MIDP-2.1 CLDC-1.0 MIDP-2.1 CLDC-1.0 MIDP-2.

‡ MIDlets are designed to support a particular MIDP version and are guaranteed to work properly with mobile devices that support that version 31 .MIDlets ‡ An application written for MIDP is called a MIDlet. ‡ MIDlets are portable across compatible mobile devices that support the same optional APIs that the MIDlet itself uses.

and more. the names and classes for each MIDlet in the suite.MIDlets ‡ A MIDlet suite consists of a Java Application Descriptor file (.jar). ‡ The JAD file includes the archive file name. 32 .jad) and a Java Archive file (. ‡ The JAR file contains the MIDlet classes and resource files.

MIDlets
‡ In order to be classified as a MIDlet, a mobile Java application must:
± extend the MIDP-defined abstract class javax.microedition.midlet.MIDlet, which controls the MIDlet lifecycle ± be packaged and distributed in a Java Archive ( JAR) file. ± include a MANIFEST.MF file contained within the .jar file. ± include a Java Application Descriptor ( JAD ) file. ± have all .class files preverified before deployment. In current Java ME tools, the preverification is done automatically during the build process. 33

MIDlet Suites
‡ One or more MIDlets are packaged in a single jar file and distributed as MIDlet suites. ‡ They have greater ability to share external resources than separate MIDlets. ‡ All of the MIDlets in a suite are installed onto a device as a single entity. ‡ At runtime, if the device supports concurrent running of more than one MIDlet, all active MIDlets from a MIDlet suite run in the same Java VM.
34

Toolkits
‡ ‡ ‡ ‡ ‡ Sun Java Wireless Toolkit ( WTK ) Netbeans Nokia SDK Samsung SDK Motorola SDK

35

Java Development Environments
‡ Java SE, JDK latest version ‡ Java Wireless Toolkit ( WTK ) ‡ IDE, Eclipse with java Mobile plugin ( Eclipse ME ) or Netbeans with Java Mobility pack ‡ SDK supporting Java ME and MIDP
± SDKs for S60 and Series 40 Nokia mobile can be downloaded from nokia site ( www.forum.nokia.com ) ± Supporting emulators for the devices

‡ A mobile device and a means to connect it to your PC for MIDlet testing purposes ‡ Nokia PC Suite to enable the transfer to the physical phone
36

Hands on WTK for Mobile Apps

The Development Cycle ‡ Standard Development Cycle 38 .

Step 1 ‡ Install Java SE ( JDK ) ± J2SE 5. ± it includes a Java compiler and other tools that the toolkit uses to build your projects.0 ( or later ) to form the foundation of your development environment ± provides the Java platform upon which the Sun Java Wireless Toolkit runs. ‡ Install latest Java Runtime ( JRE ) 39 .

it automates several of the tasks related to building MIDP applications ± The files for the toolkit will go into c:\WTK23 unless you specify a different directory ± Does not have an editor !!! 40 .Step 2 ‡ Installing Sun Java Wireless Toolkit ± set of tools that make it easy to build and test MIDP applications ± a miniature IDE.

Step 3 ‡ Run the toolkit ± Select the KToolbar shortcut 41 .

where the end result of each project is one MIDlet suite. and run the project in a device emulator 42 . build the project. ‡ You can change properties of the current project.Step 3 contd ‡ The Sun Java Wireless Toolkit works with projects. ‡ The toolkit works with one project at a time.

± The toolkit prompts you for a project name and the name of a MIDlet class in the project.Step 4 ‡ Create a new project ± Click on New Project in the button bar. 43 . Fill in HelloSuite and HelloMIDlet as shown below.

Creating project "HelloSuite" Place Java source files in "C:\WTK23\apps\HelloSuite\src" Place Application resource files in "C:\WTK23\apps\HelloSuite\res" Place Application library files in "C:\WTK23\apps\HelloSuite\lib" 44 .Step 4 contd ‡ Create a new project ( contd ) ± click on ³Create Project´ and press OK to finish creating the new project .

jad file). 45 .jar file) and the MIDlet suite descriptor (a . ± name of the subdirectory is the same as the name of the project ± Each project subdirectory has a standard structure: ‡ The bin directory contains the compiled MIDlet suite (a .Step 4 contd ‡ Create a new project ( contd ) ± The toolkit stores each project in a subdirectory of the apps directory .

java in the src directory of your project 46 .Step 5 ‡ Write code for a small MIDlet ‡ Save code as HelloMIDlet.

Step 6 ‡ Build the project ± Click on the Build button in KToolbar ± Additional directories (classes. and tmplib ) are created as follows 47 . tmpclasses.

Step 7 ‡ Run the MIDlet on the emulator ± Click on the RUN button. You should see a mobile phone emulator pop up. ± The emulator is showing a list of MIDlets in the MIDlet suite ( presently only one ) 48 .

Step 8 ‡ Run in Emulator ± click on the LAUNCH soft button to start up the MIDlet. ± It will display a simple screen with the response 49 .

± Close the emulator window or hit the Escape key to end the emulator session.Step 9 ‡ Exit ± Click on EXIT to leave the MIDlet. 50 .

± The Sun Java Wireless Toolkit has other emulators as well. Simply select the emulator you'd like in the combo box in KToolbar. 51 .Step 10 ‡ Other Emulators ± The emulator you've just used is the Default Color Phone. then click on RUN again. Try running HelloMIDlet on some other devices to see how the user interface adapts.

Nokia SDK ‡ Third party SDKs also can be used 52 .

MIDlet Life cycle .

‡ The core of the MIDlet lifecycle is the AMS. 54 .Application Management Software ‡ The Application Management Software (AMS) manages the MIDlets. which provides the context for all MIDlet activities ‡ The AMS is a part of the device's operating environment and manages MIDlets states during the execution process.

‡ The AMS maintains control over the MIDlet lifecycle throughout its execution. which starts the lifecycle of the MIDlet. 55 . the AMS instantiates it by calling the MIDlet's startApp method.AMS ‡ When a mobile device user selects a MIDlet for execution. There are no explicit restrictions to the number of MIDlets that can run simultaneously. the AMS can release resources by terminating inactive MIDlets or pausing active ones.

or other events ( like a phone call ) 56 . actions initiated by other applications. ‡ The AMS can send a MIDlet to the background or bring it to the foreground either as a response to user initiated actions.AMS ‡ The AMS controls what is shown on the device display using the concepts of foreground and background. ‡ Only one application is active at a time. with all the other running applications relegated to background. and it is in the foreground.

FG ± BG Switching ‡ In a foreground MIDlet. This causes view activation in the native operating system. call Display. The next application getting the foreground is determined by the platform.setCurrent(Displayable). calls Display. ‡ To activate a background MIDlet and set it to the foreground. which results in the MIDlet being brought to the foreground. 57 .setCurrent(null) to send the MIDlet to the background.

the AMS terminates the MIDlet forcefully. 58 .AMS ‡ The system can close a MIDlet at any time. forcing the application to a graceful exit. for example due to shortage of resources such as memory. ± If this fails. ± The AMS calls the MIDlet's destroyApp() method.

MIDLet Life cycle 59 .

‡ All MIDlets extend the MIDlet class: public class MyMIDlet extends MIDlet { } ‡ The MIDlet class provides methods for starting. pausing.MIDlet Structure ‡ An application written for MIDP is called a MIDlet. and terminating the MIDlet application: ± startApp() ± pauseApp() ± destroyApp(boolean unconditional) 60 .

If a runtime exception occurs during startApp. the MIDlet will be destroyed immediately. the MIDlet is in Active state and the AMS allows it to hold resources. After startApp.MIDlet Structure ‡ Every MIDlet must have three methods: ± startApp method is called when the MIDlet is started. 61 .

MIDlet Structure ‡ Every MIDlet must have three methods: ± pauseApp method is used to indicate actions when the app is to be set to the paused state. it still needs to be included as a null method 62 . pauseApp() isn't called but it can be set to be called with specific functions to handle flipclose() type of operations ± Even if pauseApp() is not called. By default.

± A MIDlet can be closed in several different scenarios ‡ ‡ ‡ ‡ an End key press by AMS memory card removal out-of-memory situation 63 . all the MIDlet's resources are released and objects deleted. ± The MIDlet has five seconds to handle the destroyApp call.MIDlet Structure ‡ Every MIDlet must have three methods: ± destroyApp signals the MIDlet to terminate and places it in Destroyed state. During termination. after which the AMS closes the application itself.

getDisplay(this).15.lcdui.0).microedition.setCurrent(textBox).*. "Hello world :=)". } public void pauseApp() { } public void destroyApp(boolean unconditional) { } } 64 .*.midlet. import javax. Display.microedition. public class HelloMIDlet extends MIDlet { public void startApp() { TextBox textBox = new TextBox(³My MIDlet".Complete MIDlet Example import javax.

MIDP API Programming .

and the user can traverse only through the items on that screen.MIDP UI ‡ The central abstraction of the MIDP UI is a screen. ‡ Only one screen can be visible at a time. ‡ 3 types of screens 66 . which is an object that encapsulates device-specific graphics rendering user input.

The application can add text. ± Generic screens that use a Form component.MIDP UI ‡ There are three types of screens: ± Screens that encapsulate a complex user interface component that involves a List or TextBox component. 67 . and a simple set of related UI components to the form. images. ‡ The Display class is the display manager that provides methods to retrieve information about the device's display capabilities. such as a subclass of the Canvas class. ‡ A screen is made visible by calling the Display. ± Screens used within the context of the low-level API. The structure of these screens is predefined. and the application cannot add other components to these screens.setCurrent() method.

It is designed for applications that need precise placement and control of graphic elements and access to low-level input events . ‡ Low Level API provides little abstraction. 68 .MIDP GUI objects ‡ Organised as High Level API & Low Level API Objects ‡ The high-level API is designed for applications whose client parts run on mobile information devices where portability is important.

High Level API ‡ To achieve portability. ‡ Interaction with components is encapsulated by the implementation ‡ When you use the high-level API. the underlying implementation does the necessary adaptation to the device's hardware and native user interface style. the API employs a highlevel abstraction and gives you little control over its look and feel. ‡ The high-level API is implemented by classes that inherit from the Screen class. 69 .

com/techtopics/mobility/midp/articles/ui/ .sun.High-Level MIDP GUI ‡ ‡ ‡ ‡ ‡ ‡ ‡ Alert DateField Form Gauge List TextBox TextField 70 http://developers.

High-Level MIDP GUI Command CommandListener interface 71 .

72 . ‡ MIDlets that access the low-level API are not guaranteed to be portable because this API provides mechanisms to access details that are specific to a particular device. The Canvas and Graphics classes implement the low-level API.Low Level API ‡ This API gives the application full control over what is being drawn on the display.

com/techtopics/mobility/midp/articles/ui/ 73 .sun.Low-Level MIDP GUI ‡ ‡ ‡ ‡ Canvas Raw input event Command CommandListener http://developers.

Low-Level MIDP GUI http://developers.com/techtopics/mobility/midp/articles/ui/ 74 .sun.

CommandListener. ‡ The lcdui package contains three interfaces (Choice.lcdui package ‡ All MIDP GUI classes are in the lcdui package. your MIDlets have to import this package as follows: import javax.*. ItemStateListener ) and twenty one classes 75 .lcdui. To use the GUI classes.microedition.

lcdui ‡ Class diagram for lcdui class 76 .

Some Examples 77 .

78 .RMS ‡ Several applications need to store some data in a permanent way (even when the device is switched off) ‡ This kind of data is called ³persistent data´ and they are stored in a dedicated memory part called ³persistent storage´ ‡ MIDP defines a set of classes for storing and retrieving persistent data called Record Management System (RMS).

RMS ‡ The basic storage mechanism used by the RMS is a ³Record Store´ implemented as a simple recordoriented database ‡ A Record Store can be shared among different MIDlets (only MIDP 2.0) 79 .

if your MIDlets use multiple threads to access a record store. or some of the records might be overwritten. we need to synchronize this access. and serialized. so no corruption occurs with multiple access.RMS ‡ The MIDP RMS implementation ensures that all individual record store operations are atomic. ‡ When a MIDlet suite is removed from the device then all the record stores associated with it will also be removed 80 . synchronous. However.

RMS ‡ To use the RMS. ± Allow MIDlets in the same application to share records (access one another's record store directly). 81 . ± Do not provide a mechanism for sharing records between MIDlets in different applications.rms package ‡ Record stores (binary files) are platform-dependent because they are created in platform-dependent locations.microedition. import the javax. ‡ The RMS APIs provide the following functionality: ± Allow MIDlets to manipulate (add and remove) records within a record store. ‡ MIDlets within a single application (a MIDlet suite) can create multiple record stores (database files) with different names.

and MMS. e-mail. Bluetooth. Infrared. 82 . installation over a serial cable.Deploy your MIDlet ‡ Once the MIDlet has been run on an emulator. ± ± ± ± ± ± Over-the-Air (OTA). the next step is to run it on the target device. There are a number of ways to deploy a MIDlet to a device.

Serial Cable ‡ If the device has a serial cable port and connectivity software for a PC. the MIDlet can be installed on the device over a serial cable ( USB ). ‡ Nokia PC Suite handles it as a simple application 83 . ‡ How the received MIDlet is handled when it reaches the device will be device specific.

84 . For example. etc.IR / Bluetooth Deployment ‡ IR or Bluetooth technology can be used to send the MIDlet from a PC to another device. ‡ These methods of deployment are dependent upon having access to an IR pod or Bluetooth connection suport. the MIDlet may go into the Messaging Inbox. the AMS may be automatically or manually activated and handle the MIDlet. ‡ How the device handles the sent MIDlet will be device specific.

± Trusted Source ???? 85 . ‡ When the e-mail/MMS is opened. the AMS will automatically be activated and provide an option to install the sent MIDlet.E-mail and MMS ‡ A JAR file could be included as an attachment to an e-mail or within an MMS.

Designing the user interfaces Although it maintains a constrained profile. the MIDP API provides a complete set of UI elements. The following are some of the most important ones: ‡ An Alert acts as a screen to provide information to the user about an exceptional condition or error. 86 . ‡ A Choice implements a selection from a predefined number of choices.

‡ A List provides a list of choices.‡ A ChoiceGroup provides a group of related choices. ‡ A StringItem acts as a display-only string. 87 . ‡ A Form acts as a container for the other UI elements. ‡ A TextBox is a screen that allows the user to enter and edit text.

Multiple TextFields can be placed in a Form.‡ A TextField allows the user to enter and edit text. 88 . ‡ A DateField is an editable component for presenting date and time information. A DateField can be placed in a Form. ‡ A Ticker acts as a scrollable display of text.

. 89 . .Q&A ‡Time for a few Questions ‡If none. . .

THANKS The greatest difficulty in the world is not for people to accept new ideas but to make them forget about their old ideas. .John Maynard Keynes 90 .

Sign up to vote on this title
UsefulNot useful