Table of ContentsChapter 19.            CLDC 1.1 and MIDP 2.0Developing with MIDP 2

The Next Generation

In response to the growing capabilities of mobile devices, Sun released an expanded version 2 of the MIDP in November, 2002. The new version raises the bar on the capabilities and includes a host of new features.

Along with MIDP 2, the CLDC was expanded to version 1.1, also incorporating many new features. Note though that while you can employ CLDC 1.1 and MIDP 2.0 together, MIDP 2 does not require CLDC 1.1, so a device featuring MIDP 2 support does not necessarily implement CLDC 1.1. In fact, support for CLDC 1.1 is far behind MIDP 2. Therefore, most of the time you should target MIDP 2 and CLDC 1.0.4 for development.

CLDC 1.1

Even though it's not widely supported, you should take a quick look at the new features available in CLDC 1.1. The interesting additions are

  • Support for floating point

  • Support for weak references

  • An increase in the minimum memory a device requires from 160 KB to 192 KB

NOTE

Note

CLDC 1.1 also incorporates some more minor things you should take note of. None of these are life changers, but they're nice to have anyway (such as the String.equalsIgnoreCase method). These additions include the following features:

  • Threads now have namesThread.getName()and you can interrupt them Thread.interrupt().

  • The NoClassDefFoundError was added. This will be thrown if an unknown class is used.

  • Boolean.TRUE and Boolean.FALSE were added.

  • String now has intern() to gain access to an internal string representation and equalsIgnoreCase() methods which compares two strings regardless of case.

  • Random now supports the nextInt(int n).

The addition of floating point by default means you can now avoid the mess of using something like the MathFP library (which in turn saves you a little JAR space). In order to fully support floating point, the Double and Float classes have also been added.

MIDP 2

MIDP 2 is where all the really fun changes are. The new standard offers a great deal more for all types of MID developers, but especially for game programmers.

Handsets supporting MIDP 2 are starting to appear. Any Nokia Series 60 phone, for example, is usually MIDP 2 (though not CLDC 1.1) and other manufacturers are starting to release new handset versions also supporting the platform. Existing handsets, however, are generally not software upgradeable from MIDP 1 to MIDP 2. (Note though that most existing MIDP 1 capable devices are still being released with MIDP 1, not MIDP 2.)

The changes in MIDP 2 come in three main categoriesthings that you can count on in every implementation, things that are likely to be supported, and things that might be supported. Let's start with the things you know you can count on. These are

  • An enhanced LCDUI with custom controls, spacers, and revised layout

  • New imaging powers providing draw region, reflection and rotation, and RGB images

  • A game library providing support for sprites and distinct drawing layers

  • Support for sound (tones)

  • PNG image transparency

  • Onscreen feedback of any network usage

  • The ability to share RMS data among MIDlets

  • Secure HTTP (HTTPS)

NOTE

Note

The MIDP 2 specification recommends that devices not let the user copy a MIDlet unless some type of copy protection system is in place.

The next set of functions is most likely supported, so for the most part you can count on these functions being available. A manufacturer will only exclude these if there's a good reason (such as a device limitation). For this reason most MIDP 2 implementations include these features, so it's quite reasonable to develop with these in mind. However, you will have to check whether they are supported on all devices (and networks) on which you intend to have your game run. The significant features in this category are

  • WAV sounds (minimum 8 KHz mono)

  • Datagram connections (UDP)

  • Direct socket streaming connections (including secure ones)

In addition, optional components may be made available. Since it's completely optional for a manufacturer (or a network provider) to include these, you'll need to check on their availability on your target devices.

  • Push protocols (where the MIDlet will "wake up" when traffic is received or at a certain time)

  • Server sockets (allowing incoming connections to the device)

  • Access to a device's serial ports

NOTE

Note

MIDP 2 specifications require backward compatibility with all MIDP 1 functions. This means any MIDP 1 game will run on an MIDP 2 device.

Now that you've seen what's offered, take a look at how to set up for MIDP 2 development.

NOTE

Is MIDP 1 an Upgrade to MIDP 2?

One thing you need to keep in mind about MIDP 2 is that it's a little like the different Star Trek series. The original version is still out there and well supported. The next generation is a lot more capable, has a much bigger budget, and looks a lot better, but it's certainly not an enhanced version of the original. They are separate entities designed to coexist. MIDP 2 is not intended to replace MIDP 1, no matter how old MIDP 1 looks compared to more modern versions.

This is illustrated by the common mistake of trying to use the version 2 Wireless Toolkit from Sun to develop MIDP 1 games. It's easy to understand the mistake; version 2 should be an upgrade of version 1, right? Well in this case, that's not quite correct. MIDP 2 is a new standard designed for a new range of more capable phones. In other words, most MIDP 1 devices won't be able to run MIDP 2. You need to use Toolkit 1 for MIDP 1 development and Toolkit 2 for MIDP 2 development.

Personally, I think Sun should have called MIDP 2 something like MIDP Generation 2 to try and reinforce the fact that it's not really an upgrade. After all, it's only natural for developers to assume something labeled 2.0 is a replacement for version 1.0.

The important thing is that the release of MIDP 2 does not signify the demise of MIDP 1. A device manufactured with the primary purpose of being a phone doesn't really need the capabilities mandated as part of the MIDP 2 specifications. Down at the budget phone end of the market, the manufacturers are under enormous pressure to keep handset prices down. Monochrome screens, limited memory, and slow CPUs aren't going anywhere anytime soon.

    Table of ContentsChapter 19.            CLDC 1.1 and MIDP 2.0Developing with MIDP 2