Introduction to JME
In order to understand how Java 2 Micro Edition J2ME lies within the wider Java landscape it is best to explore the overall Java architecture. J2ME has been developed primarily as a technology for the execution of applications on constrained devices. In this case, constrained devices are mobile phones, PDAs, TV set-top boxes, in-vehicle telemetry, residential gateways and other embedded devices. J2ME as a whole can be described as the technology that caters for all these devices. Given that...
The Picture Puzzle
This case study describes a simple game that uses the Mobile Media API to take photographs using a camera phone. The sample MIDlet also illustrates using the RMS store to save, load and delete persistent records and makes use of a TiledLayer from the Game API. The Picture Puzzle MIDlet is a variation on the familiar Mix Pix native application that ships on Nokia Series 60 phones. In this sample MIDlet we use the on-board camera to capture a snapshot that acts as the original image. The MIDlet...
Polling
Avoid using loops that poll. The following is a snippet of code that polls the keepRunning flag. printText String just displays String in a UI component. printText Started while keepRunning Running the loop increased battery consumption from 66 mA to an unacceptable 163mA on my Psion Series 5MX unfortunately there is no easy way of monitoring battery consumption on more recent mobile phones . The battery consumption returned to 66 mA when keepRunning was set to false. Further, loops like this...
MMAPI and the MIDP Security Model
For reasons of privacy the following Mobile Media API calls are restricted under the MIDP 2.0 security model see Mobile Media API Specification 1.1 Maintenance Release at http jcp.org. locator stream type . Under the MIDP 2.0 security model, a signed MIDlet suite which contains MIDlets that make use of these APIs must explicitly request the appropriate permission in its MIDlet-Permissions attribute. The required MIDlet-Permissions attribute entries in the JAD file or manifest are as follows...
Toolkits
2.3.1.1 J2ME Wireless Toolkit 2.1 Overview The J2ME Wireless Toolkit 2.1 provides basic tools for developers to create MIDP 2.0 applications. The Wireless Toolkit WTK was created by Sun to facilitate MIDP development. At the time of writing, the production release can be obtained free of charge from Sun's website Amongst more advanced features, it provides the developer with the ability to compile, pre-verify and package MIDlet suites on the command line, as well as providing a simple GUI to...
Authentication
Authentication refers to the process of verifying the identity of a remote device. The authentication mechanism in Bluetooth is based on a PIN number shared between devices. A Bluetooth server can require client authentication by adding the optional authenticate true parameter to the connection URL, as shown below. StreamConnectionNotifier service Similarly, clients can request server authentication in the connection URL. In the absence of the authenticate true parameter, either client or...
Java Bluetooth API and the MIDP Security Model
A signed MIDlet suite which contains MIDlets that open Bluetooth connections must explicitly request the appropriate permission in its MIDlet-Permissions attribute. To make outgoing client connections the MIDlet suite must request the permission. To accept incoming server connections the MIDlet suite must request the javax.microedition. io.Connector.bluetooth.server permission. For example, the MIDlet-Permissions attribute entry in the JAD file may be as follows. MIDlet-Permissions If the...
Rococo Impronto Simulator
The Impronto Simulator from Rococo Software is an ideal way for developers new to JSR 82 to explore the APIs and for more experienced developers to produce prototypes of Java Bluetooth applications. The Impronto Simulator runs Java Bluetooth applications in a simulated Bluetooth environment, allowing developers to easily test and configure applications before deploying them on Bluetooth devices. Since the Impronto Simulator provides total software emulation, developers can start programming JSR...
The Push Registry
One of the exciting new additions to MIDP 2.0 is the Push Registry API, which allows MIDlets to be launched in response to incoming network connections. Many applications, particularly messaging applications, need to be continuously listening for incoming messages. Previously, to achieve this a Java application would have had to be continually running in the background. Although the listening Java application may itself be small, it would still require an instance of the virtual machine to be...
Exception Classes
The Date class represents a specific instant in time with a millisecond precision. The TimeZone class represents a time zone offset and also works out daylight savings. An instance of this class is used to generate series of pseudo-random numbers. The Math class contains methods for performing basic numeric operations. The Exception class and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch. Thrown when an application tries to...
JME on Symbian OS
Java on Symbian OS has a long history dating backto Symbian OS Version 5 released in 1999 . This initial Java offering was based on Sun's JDK 1.1.4 platform. For the next major release, Symbian decided to take advantage of the reduced memory footprint offered by PersonalJava compared to the burgeoning JDK and used the PersonalJava 1.1.1 specification as the basis for the Java implementation. This release, Symbian OS Version 6.0, became available in 2000. PersonalJava was the forerunner of J2ME...
MMAPI on Symbian OS Phones
We next look at the important question of which media capabilities are supported in practice on the various Symbian OS phones on the market. It is important to understand that when we talk about MMAPI on Symbian OS we are not talking about a single version but three, based on two distinct implementations. These are Symbian MIDP 2.0 Audio subset on Symbian OS Version 7.0 Series 60 Developer Platform 1.0 on Symbian OS Version 6.1 Series 60 Developer Platform 2.0 on Symbian OS Version 7.0s . These...
Darren Holland
Darren joined Symbian in 2002. He graduated in 1995 with a BSc in Computing Systems Technology and started his career developing telephone billing and enterprise fax software in C before starting to work with Java in 1999. Darren would like to thank the IS department of Symbian who provided support throughout the development of the Expense application prototype, ensuring that the resources and infrastructure required were in place. More importantly, they supported the project remit and supplied...
Maximum Transmission Unit
Remember that L2CAP is a packet-based protocol. The maximum transmission unit MTU is the maximum size of a packet of data that can be sent over the L2CAP link. By default this size is set to 672 bytes. However, the Java API does give us the option to specify different values as part of the connection URL passed into the open method as will seen in later sections . MTUs can be specified for transmitting and receiving data. Specifying MTU values when opening a connection does not mean that...
Sample Code
In this section we shall consider a small peer-to-peer application that transmits an image between two Bluetooth devices using the Serial Port profile over RFCOMM. First we consider a MIDlet that offers a service to receive and display an image. The classes making up the BT Demo Server MIDlet are depicted in Figure 4.7. Figure 4.7 A UML class diagram of the BT Demo Server MIDlet. Figure 4.7 A UML class diagram of the BT Demo Server MIDlet. The BTDemoServer code is listed below. import...



