1. Overview

JAVA TECHNOLOGY IS enjoying a rock star career in the mobile phone industry. After starting in Japan in 1999 as NTT DoCoMo’s i-mode service, the lead singer of the band, the Mobile Information Device Profile (MIDP) is now deployed on over 2.1billion mobile devices worldwide (according to information available at http://java.sun.com/javaone/sf/2007/articles/mobilitygeneralsession.jsp).

This chapter explains why MIDP is such a good fit for mobile devices and describes how MIDP and the rest of the band fit together to form a powerful platform for mobile applications.

1.1. Not Plastics, but Wireless

In an updated version of the 1967 classic The Graduate, the young hero of the film would be urged to get involved in the wireless industry. The revolution of desktop computers has come and gone. The new revolution is wireless devices, which provide a cheap, lightweight, and often stylish portal to the full power of the Internet.

Mobile phones already outnumber desktop computers as a method of connecting to the Internet, and the trend will only continue. With more and more applications moving from the desktop to the Internet, a mobile phone is a much simpler and more convenient alternative to a desktop computer or even a laptop.

The wireless networks of today are still slow compared to cable modem and DSL technologies that are available in many homes. Nevertheless, much useful work can be done with a wireless device. Faster networks, which will open up new worlds of applications, are deployed in some parts of the world and will become widespread in the next couple of years.

1.2. MIDP, the Heart and Soul of Mobile Java Technology

MIDP is the foundation of most Java technology mobile applications today. This might change in the future, as you’ll see later, but for the moment, MIDP dominates the world of Java technology on mobile devices.

MIDP is a specification defined by a consortium of interested companies and individuals through the Java Community Process (JCP). Specifications defined through the JCP are called Java Specification Requests (JSRs), and each is assigned a number.

The first MIDP specification was JSR 37, published in September 2000. MIDP 1.0 defines a complete environment for Java technology applications to run on small devices.

MIDP 1.0 actually builds on another specification, the Connected, Limited Device Configuration (CLDC). CLDC 1.0 is defined by JSR 30. CLDC defines the behavior of the Java Virtual Machine (JVM) that is used on mobile devices and provides some basic APIs. MIDP adds APIs for applications and user interfaces.

The complete set of software on a mobile device is often called a stack. The very first MIDP phones had the Java technology stack shown in Figure 1.1.

Figure 1.1. Initial MIDP stack

Image

While MIDP 1.0 phones were being sold to the public, the MIDP 2.0 specification was already underway. It addressed shortcomings in MIDP 1.0 and added new features for gaming, enhanced user interface, and secure networking.

MIDP 2.0 is widely deployed on mobile phones today.

The reason MIDP is so popular with device manufacturers and wireless network operators (carriers) is the JVM. Native applications execute instructions directly on a device’s processor. Badly behaved native applications can crash the entire device. A badly behaved Java technology–based application (Java application) will, at worst, crash the JVM, leaving the rest of the device still running smoothly. Device manufacturers and carriers like this design because it gives their users a degree of safety in running third-party software.

1.3. The First Umbrella: JTWI

Other JSRs, called optional APIs, were also being created at the same time that MIDP was growing up. The first optional APIs to be completed were for text messaging (JSR 120, Wireless Messaging API, or WMA) and multimedia support (JSR 135, Mobile Media API, or MMAPI). Since then, many more have been added: support for Bluetooth networking, Global Positioning System (GPS) hardware, 3D graphics, and enhanced multimedia are just a few.

The abundance of optional APIs became a challenge. As an application developer, how could you figure out which APIs you expected to be available on a device?

The first answer to this question was a specification called Java Technology for the Wireless Industry (JTWI, JSR 185). JTWI is an umbrella specification. It incorporates MIDP 2.0, CLDC 1.1 (or 1.0), WMA, and MMAPI. Support for MIDP, CLDC, and WMA is required, but MMAPI is optional (see Figure 1.2).

Figure 1.2. JTWI stack

Image

Beyond merely assembling its component specifications, JTWI defines other requirements for implementations, such as minimums for memory, minimums for multithreading, and the behavior of APIs. The goal is to reduce ambiguity and provide application developers with a robust, predictable platform.

1.4. A Bigger Umbrella: MSA

JTWI provides a well-defined application environment. Many new APIs have been completed since JTWI was defined. JSR 248, the Mobile Service Architecture (MSA), is a newer umbrella specification, again based on MIDP 2.0. MSA is backwards compatible with JTWI but expands it considerably.

MSA defines two umbrellas. One is MSA, the other is the MSA subset. The subset is designed for devices that don’t have the hardware power to support the full MSA stack (shown in Figure 1.3).

Figure 1.3. MSA stack

Image

If you don’t recognize some APIs in the diagram, don’t worry. The next section is a quick fly-through of the APIs that are part of MSA. The rest of the book describes the APIs in detail.

APIs are either mandatory or conditionally mandatory in the MSA specification. APIs that require specific hardware, such as Bluetooth networking or GPS, are conditionally mandatory. The JSR 179 Location API, for instance, is conditionally mandatory because not all devices will have hardware that determines the device’s location.

Some JSRs contain more than one API definition. JSR 177, for example, defines four APIs. In the MSA specification, one is not required at all (SATSA-JCRMI), two are conditionally mandatory depending on the smart card hardware available (SATSA-APDU and SATSA-PKI), and one is mandatory (SATSA-CRYPTO).

1.5. Understanding MSA APIs

Although Figure 1.3 is a big hairy pile of acronyms and numbers, it’s easier to understand the whole picture when the APIs are grouped together by topic. Remember, you are just getting the broad outlines of MSA here. The rest of the book covers the APIs in detail.

1.5.1. Basic MIDP Platform

The fundamental application platform is based on CLDC and MIDP. CLDC provides a small JVM and fundamental APIs. MIDP adds APIs for user interface, application model, persistent storage, and HTTP and HTTPS networking.

MIDP also includes a push registry so that applications can be launched in response to incoming network activity.

1.5.2. Advanced Networking

JSR 120, WMA 1.1, enables applications to send and receive text messages using Short Message Service (SMS) or Cell Broadcast Service (CBS). The next version, JSR 205 or WMA 2.0, allows sending and receiving images and other media via Multimedia Message Service (MMS).

Devices that have Bluetooth hardware will implement the JSR 82 Bluetooth API. Devices with appropriate Bluetooth or infrared hardware can also implement the JSR 82 OBEX API.

MSA also includes JSR 180 Session Initiation Protocol (SIP) API, which is a standard way to set up communication sessions.

1.5.3. Multimedia

JSR 135, MMAPI, provides capabilities for playback and capture of media. The actual formats and protocols that are supported are determined by the capabilities of the device. A small subset of MMAPI for playing audio files is included as part of MIDP.

JSR 234, Advanced Multimedia Supplements (AMS), extends MMAPI with better support for cameras and new features for audio effects and 3D audio.

1.5.4. Advanced Graphics

MIDP 1.0 provides excellent capabilities for building user interfaces using predefined types as well as custom drawing. MIDP 2.0 adds more, including a game API.

MSA builds on MIDP’s graphics capabilities with two advanced graphics APIs. The first is JSR 184, the Mobile 3D Graphics (M3G) API for J2ME. Applications can use M3G to build 3D scenes on the fly or load them from files.

JSR 226, the Scalable 2D Vector Graphics API, allows applications to play industry-standard scalable vector graphics (SVG) content.

1.5.5. Security and Transactions

MIDP 2.0 requires support for HTTPS connections, which is sufficient security for many applications. In addition, MSA includes APIs for communicating with a smart card and making payments.

JSR 177, Security and Trust Services APIs, defines four APIs. Three are part of MSA. SATSA-APDU and SATSA-PKI are useful for applications that want to use a smart card to do work or perform cryptographic operations. They provide an additional level of security for especially sensitive data. Both SATSA-APDU and SATSA-PKI are conditionally mandatory depending on the available hardware. SATSA-CRYPTO is a general-purpose cryptographic API and is a mandatory component of MSA.

Applications that allow users to make payments can use the JSR 229 Payment API. For example, a game that allows users to buy new levels or lives could use the Payment API.

1.5.6. Location

The JSR 179 Location API provides applications access to a device’s physical location. Obviously, this works (and the Location API is available) only if the device has some way of determining its own location. Most of the time, the method is GPS.

1.5.7. Advanced Application Invocation

MIDP 2.0 provides a push registry for launching MIDlets in response to incoming network activity. MSA provides another way to launch applications, the JSR 211 Content Handler API (CHAPI). In essence, CHAPI maps content types to applications. If the device receives a movie file, for example, an application can be configured to launch and view the content.

1.5.8. Advanced Application Services

Finally, MSA provides three APIs to round out a highly capable application environment.

JSR 75 provides two important APIs. The Personal Information Management (PIM) API allows applications to read information stored in a device’s phone book, calendar, and contact list. The FileConnection API gives applications the capability to read and write files stored on a device.

JSR 172 defines APIs for Web Services. MSA requires just one, the Java API for XML Parsing (JAXP).

Finally, the JSR 238 Mobile Internationalization API (MIA) defines a resource file structure and supporting API to make it easy to create multilingual applications that can be distributed to a global audience.

1.6. Looking beyond MSA 1.0

Although MIDP is the centerpiece of small device Java Technology, the landscape is constantly shifting. Stacks based on the Connected Device Configuration (CDC) are more appropriate for devices that are slightly larger than mobile phones, like Personal Digital Assistants (PDAs) and car navigation systems. CDC stacks are maturing more slowly than their CLDC counterparts, but their time is coming soon. CDC looks and acts more like desktop Java technology than CLDC does, so more sophisticated applications can be deployed on CDC stacks.

As if that weren’t confusing enough, it’s also likely that CDC stacks will include a MIDP implementation built on top of CDC.

The CDC counterpart to MSA is JSR 249, Advanced Mobile Service Architecture.

Another wrinkle to consider is JSR 271, MIDP 3.0, which won’t be finished until well after MSA 1.0. You can track the progress of both JSR 249 and JSR 271 at the JCP Web site.

1.7. What about JavaFX Mobile?

Just before I finished writing this book, Sun Microsystems announced the JavaFX product line. JavaFX has two components with little overlap:

  • JavaFX Script is a new programming language for quickly creating applications. JavaFX Script tools will make it easy for graphic designers and other non-geeky people to create applications for Java ME devices.

  • JavaFX Mobile is a software stack for mobile phones. It is based on CDC and, in general, is slightly “larger” than CLDC/MIDP in terms of processor power and memory size. The exact specifications of JavaFX Mobile are evolving now, but JavaFX Mobile will be able to run MIDlet suites as well as CDC applications.

Much of what you learn in this book will be useful in the future world of JavaFX Mobile. More information on JavaFX Mobile is available here:

http://www.sun.com/software/javafx/mobile/

1.8. Summary

MIDP is the core of Java technology mobile applications. Umbrella specifications group MIDP with other APIs to form a full-featured application environment. The first grouping was JTWI. The next, MSA, is the subject of this book. MSA includes APIs for text and multimedia messaging, multimedia, 3D graphics, XML parsing, advanced networking, and much more.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.171.51