Developer Product Briefs
Evolving Java for Series 40 Devices
For mobile app developers Nokia's high-volume Series 40 platform offers a wealth of opportunities for Java development. See how the latest edition's APIs are evolving the platform.
Evolving Java for Series 40 Devices
Check out the API additions that enhance application development opportunities for Series 40 Platform 3rd Edition.
by Alex Haynes
April 17, 2006
Mobile Java applications offer developers a significant opportunity to extend the commercial reach of their Java skills. To effectively take advantage of these opportunities developers need consistent implementation of Java technology and a large marketplace of mobile consumers. Nokia takes a platform approach to device creation, which means that while devices may offer unique designs and features for specific markets, the underlying Java technology is uniformly implemented. An application designed for one device can easily be optimized for another device that is based on the same platform. You can build and deliver mobile applications for a global audience in less time, with less effort, and at a lower cost.
For any Java developer the Series 40 platform is excellent for beginning a foray into mobile development. Let's take a look at the latest release of the platform, Series 40 Platform 3rd Edition, and discuss the API enhancements that allow you to create more appealing applications that offer higher value to mobile users.
The Series 40 Platform 3rd Edition builds on the strong foundation provided by Series 40 2nd Edition, where Connected Limited Device Configuration (CLDC) 1.1 and Mobile Information Device Profile (MIDP) 2.0 were introduced, and extends the platform to meet the growing demand for application functionality. Series 40 Platform 3rd Edition is an evolutionary technology, and as such it is generally backward compatible with both the first and second editions of the Series 40 platform.
Series 40 Platform 2nd Edition gave developers the ability to create applications that use Bluetooth technology through JSR 82, send Short Message Service (SMS) messages through JSR 120, and play back tone and MIDI sounds through JSR 135. The second edition works with 128x128-pixel screens, displaying images in 16-bit color. Series 40 Platform 3rd Edition builds on these features, providing important new functionality for Java applications and support for screens of up to 240x320 pixels in 32-bit color.
While the Series 40 platform can be used for any style of Java application, games are one of the most popular. Series 40 Platform 3rd Edition enables developers to advance the quality of game play with the introduction of the Mobile 3D Graphics API (JSR 184). This API can bring visual improvements to existing games and opens the way for previously unsupported game styles. However, it is not just games that can benefit from 3-D functionality, which allows for animations and new UI components to be created within other application categories.
Devices' file system and personal information manager (PIM) lists have been restricted areas to Java applications in the past, but with Series 40 Platform 3rd Edition applications can access certain areas of a device's file system or PIM data. Applications can now access the device's gallery to manipulate images, sounds, and other files; save e mail attachments; and read and write fields for contacts, events, and to-do lists.
Multimedia APIs were first introduced in Series 40 Platform 2nd Edition; the functionality has now been extended with camera and video support in Series 40 Platform 3rd Edition, which allows applications to record and play back still images and video captured with the device's camera. The API allows for the playback of multiple video formats and paves the way for applications that play videos prepared by third parties, such as the latest episodes of current television programs or a users' favorite video podcasts.
All of these functional improvements are enhanced by the new UI style employed in Series 40 Platform 3rd Edition. The large 240x320-pixel screen displayed in 32-bit color means Java developers can benefit from the improved viewing experience provided to mobile consumers, which will drive content and media consumption. In addition, presentation changes in some of the high-level Java UI components mean that Java applications more closely resemble the native device applications.
Let's look at these changes in more detail, starting with the PDA Optional Packages for the J2ME Platform (JSR 75), which gives you access to the device's file system and PIM data. FileConnection (FC) Java applications can manipulate some of the files on a Series 40 Platform device. For example, an application could edit a sound file recorded by the native sound recorder. The modified recording could then be saved to the device's gallery and used as a ring tone. It is however a restricted API; access can be granted only to files in the device's gallery and on removable memory cards. These restrictions are to protect the user's private data and to prevent corruption of the operating system.
As a result, file operations can be executed only if the necessary permission has been acquired and then only within certain folders. The files are accessible depending on the security domain assigned to a MIDlet during installation. An untrusted MIDlet has access to images, videos, public folders, and a private directory assigned for its own use. While the FC API fills gaps in the generic connection framework (GCF) by giving access to file system and supporting file-oriented operations, it is not a replacement for the Record Management Store (RMS) API, but a complement, allowing MIDlets to interact with device data.
The PIM API (within JSR 75) provides access to contacts, events, and to-do lists in device or SIM memory. In Series 40 Platform 2nd Edition there is limited access to the device's contacts list, using a text editor in PHONENUMBER or EMAILADDR modes and restricts the application user to read-only access of a subset of the available contacts list fields. The PIM API allows an application to read from and write to any field in the PIM lists.
It is possible to have multiple lists of the same type in one device, such as a contacts list in the device memory and another in the SIM card. Each list is defined by a unique name, which is used when opening the list. The name is device dependant, but a list of names can be queried from the device. Moreover, in Series 40 Platform 3rd Edition, the list names are localized to the device's language—for example, contacts, contactos, or puhelinluettelo. Each entry in a PIM list can contain multiple fields and each contacts list can contain different fields. For example, a contacts list in the device's memory can include fields that cannot be stored in a SIM memory list.
The PIM API leaves room for variations among different manufacturers' implementations. Therefore, it is important to be aware that although there may be differences between Series 40 Platform and S60 devices, Nokia devices based on the same platform will always be consistent in their use of the API. As with JSR 75 FC, PIM is a restricted API. Users may receive prompts requesting confirmation for certain operations.
The Mobile Media API (JSR 135) has been available since the introduction of Series 40 Platform 2nd Edition, providing developers the means to develop applications with camera and video support. With the introduction of Series 40 Platform 3rd Edition the different video and audio recording standards used by GSM and CDMA are supported. CDMA devices support 3GP2 for video recording and QCELP for audio recording, while GSM devices support 3GPP for video recording and AMR narrow band for audio recording.
Players are invoked by the API using a file's MIME type, and the supported MIME types can be interrogated in MIDlet code. A player provides controls such as volume, play, pause, rewind, and fast forward, allowing simple manipulation of the content from a Java application. The Series 40 Platform 3rd Edition Mobile Media API implementation is backward compatible with the implementation in Series 40 Platform 2nd Edition.
One of the obvious features of the third edition is the support for large screen sizes. Larger than previously supported screen sizes are a significant consideration when optimizing applications for specific devices based on the Series 40 platform. Using a modular design approach makes the process of optimizing MIDlets to account for the various Series 40 Platform devices' screen size relatively straightforward.
Whether development starts with the smallest targeted screen size or the largest will depend on the graphic content of the application. Developers of graphic-intensive applications, such as games, are advised to start with the largest screen and then optimize to smaller screens. This approach is suggested because graphics will probably use the largest amount of application storage. If the application works on the largest screen, it should still do so for smaller screens as the graphics size and therefore memory usage will be reduced.
Developers of data- and function-oriented applications are recommended to start with the smallest targeted screen size and then work toward the bigger screen sizes. This approach is far easier to expand an interface design into more screen real estate than to compress a design to a smaller screen. Another aspect of flexible, adaptable applications is avoiding hard coding. Where possible, consider querying screen resolution and facilities such as automatic double buffering on initialization within the MIDlet, rather than hard coding screen dimensions or capabilities.
The new UI style includes the screen of a background image in Java applications when Liquid Crystal Display User Interface (LCDUI) components are used (in Series 40 Platform 2nd Edition a white background was provided). This UI style makes Java applications similar to native Series 40 platform applications, which use this background image. The white background required minimal consideration of readability issues in application design.
For development in Series 40 Platform 3rd Edition you need to consider these background images when using certain LCDUI components to ensure that the UI components and text is readable. For example, black text displayed over a very dark background image could be hard to read. In addition, the background image is part of the device's theme and not something the application has control over. The LCDUI components that need consideration are those that allow foreground and background colors to be controlled by the MIDlet, such as CustomItem. Applications can address this issue in a number of ways. The application could provide the user with an option to select the color of application text or set an appropriate component background color (see Figures 1 and 2).
Other enhancements have been made to LCDUI high-level components, and they more closely resemble the UI components used in native Series 40 platform applications. For example, the text editor can now be created in line within a form, whereas previously it was implemented as a separate full screen. Now a user can edit text without having to go to a new screen.
As mentioned previously, 3-D gaming is an exciting area for mobile Java application development (see Figure 3). With the Mobile 3D Graphics API (JSR 184) Series 40 Platform 3rd Edition allows applications to make use of Mobile 3D Graphics (M3G). Coupled with large screen support it makes Series 40 Platform 3rd Edition ideal for these types of games. Series 40 Platform 3rd Edition offers high-speed rendering in both intermediate and retained modes. Intermediate mode provides features similar to OpenGL, while in retained mode the API offers a scene graph. The benefit of retained mode is that a model can be constructed in software or loaded from a file. Retained and intermediate modes can be used together in the same application. The Mobile 3D Graphics API also helps simplify creating graphics because the M3G file format allows for importing models and animations built using generally available 3-D graphics tools.
Ability to Trace
From a development process point of view, one of the most important additions to Series 40 Platform 3rd Edition is the CommConnection API. This API allows a MIDlet to connect to a COM port and send data over a USB cable connected to the mobile device. While this API allows the introduction of new user functionality, such as the ability for a device application to talk to a PC application, there is a specific addition that will be helpful to your development efforts. When the COM port is not being used by the API, System.out and System.err calls in the MIDlet are directed automatically to the COM port. With a suitable cable attached to the mobile device these trace statements can be read on a PC tool, such as HyperTerminal. This feature adds a valuable trace mechanism that enables you to debug your MIDlet on the target mobile device and helps bridge the gap between testing on PC-based emulators and a mobile device.
To help you take advantage of the Java technology on the Series 40 platform you have a wide selection of tools to assist you with the development of Java applications, including browsing, messaging, and other content. The essential tools are a device or platform SDK, Carbide.j, and a Java integrated development environment (IDE). The Series 40 platform SDKs contain MIDP APIs, classes, documentation, and sample applications, along with an emulator that allows applications to be run and tested on a PC.
Carbide.j provides tools for Java ME developers to create MIDP and Personal Profile (PP) applications and deployment packages, sign applications, and deploy them to devices. It is also an essential tool for managing, configuring, and running emulators from various Nokia platform and device SDKs. Carbide.j can be used as a stand-alone tool or integrated with several popular Java IDEs. All Series 40 platform SDKs and Carbide.j are provided free of charge and can be downloaded from the Forum Nokia Web site's Tools and SDKs section (see Resources).
There are many Java IDEs available on the market that are suitable for developing applications for the Series 40 Platform. Nokia's Java tools work with the open source NetBeans and Eclipse IDEs, as well as several commercial offerings.
Series 40 Platform 3rd Edition demonstrates an effort in moving toward devices where Java applications can integrate closely with native phone applications. Applications can now access previously restricted areas of the phone memory and file system. They can get access to the device's camera for still images and video capture and use the device's playback facilities for viewing. This new functionality allows you to create media-rich applications such as an e mail client that can download, save, and view attached images or videos, and then capture an image for an immediate reply.
While larger screens with greater color depth allow more information to be presented to users in a visually appealing way, using the Mobile 3D Graphics API to create large screen 3-D games and animations will have a greater visual impact on users.
With these additions Series 40 Platform 3rd Edition continues the evolution of the highest-volume mobile platform available to you and continues to enhance your development opportunities while protecting your investment in existing applications. The platform also offers you economies of scale because of its volume of device shipments and consistent implementation of advanced Java APIs. This platform approach—with uniform implementation of technologies and supporting tools, documentation, and examples—requires less effort to seize these market opportunities and offers the best way to transition from fixed to mobile Java development.
About the Author
Alex Haynes is a Series 40 Java architect with Nokia and has been involved in the Nokia Developer Platform since the 1st Edition.