Bob Reselman shows you how to use the Java Wireless Toolkit to turn a user's cell phone into a mini tune player. Why would you want to do this? You get to learn a thing or two about writing Java code for mobile devices. And it's fun!

Like this article? We recommend

Like this article? We recommend

The Java Wireless Toolkit (WTK) is a programming environment you can use to
create Java applications that run on Java-enabled cell phones and PDAs. In an
earlier article, "The
World of Mobile Ring Tones," I showed you how to use the WTK to play
a custom ring tone. In this article, I'll go into the WTK in more depth,
covering the following topics:

Basics of the WTK framework

How to create interactive cell phone menus

MIDP Command objects

You don't need to know anything about the Java Wireless Toolkit to make
sense of this article, but I do expect that you know fundamental Java,
understand the rules of Java interface implementation, and have some knowledge
of Listener classes.

Understanding the Java WTK

The WTK emulates cell phones and other mobile devices through the Mobile
Interface Device Profile (MIDP) standard. The MIDP standard is supported by
most popular cell phone manufacturers, such as Nokia, Motorola, and Blackberry.
MIDP applications are called MIDlets. The MIDP abstracts the various
physical features of the mobile device into a set of Java classes. You
manipulate these MIDP classes to present data and graphics on the cell
phone's screen and to allow users to interact with that onscreen data. The
WTK ships with extensive documentation describing the MIDP specification and how
to create MIDP applications. In addition, the WTK provides a number of demo
applications and tutorials that show in the ins and outs of MIDP programming. In
fact, most of the application that I created for this article is adapted from
code in the AudioDemo app that comes with the WTK.

Probably the most important thing to remember about the Java Wireless Toolkit
is that it's a programming framework. The constituent classes of the WTK
handle many of the low-level aspects of programming for mobile devices. For
example, in the application that I created for this article, command key
assignment, most command processing, and screen painting are handled
automatically. Of course, you can override behaviors in order to customize your
application. But once you get the hang of the WTK, you can write a few lines of
code to get a whole lot of functionality.