|
|
www.chrfr.de |
Mobile Information Device Profile (MIDP)
This page is about MIDP, which is a software environment for
Java applications on devices with limited resources (usually
mobile phones). All mobile phones support this nowadays, so
it is your best bet to write an application which runs on
all devices with as little effort as possible. Of course,
there are also other platforms.
I wrote MIDP applications for fun and to stay in touch with
Java (and possibly for educational purposes and future career
options, although that may be a rationalization).
You may wish to check out my
minimal PNG encoder
or have a look at some games I wrote.
Find out more about Java,
MIDP, or
other platforms for mobile devices.
Tools
Basically, you just need the
J2ME Wireless Toolkit
which is available for free. This contains everything you need to
compile MIPD applications and run them in an emulator. If you are
already familiar with Java, the learning curve will be moderate
if not positively downhill. Of course, you have to forget about
the standard GUI classes like AWT and Swing, and there are more
steps required to cross-compile, preverify and package an
application.
Using an IDE will make your life a lot easier, because you can
simply create a new project, implement some functionality, hit
compile and get a packaged MIDlet. I use
NetBeans, which works
nicely and is available for free. It already comes bundled
with the Wireless Toolkit, although you can also configure
it to use separate installations, which is important if
your project targets more than one platform.
Finally, you will need a way to deploy a MIDlet on your
mobile phone. Depending on the capabilities of your phone
and PC, this can be done via data cable, infrared or
Bluetooth connection. Appropriate software is available
from the manufacturer of the mobile phone, e.g.,
Nokia PC Suite,
or from third party sources. It may already be included
in the package if you buy a data cable, infrared adapter
or Bluetooth stick.
Portability
MIDP is not the most gratifying target platform for writing
portable applications. Even a pure MIDP 1.0 application must
cope with devices differing in areas like screen size,
CPU power and threading behavior. Furthermore, multiple
versions of MIDP have been released, and some devices
feature vendor-specific API extensions. This is of
particular importance because MIDP 1.0 is lacking
even some very basic functionalities like sound,
full screen mode and direct image manipulation.
Most modern devices support MIDP 2.0, which addresses
these issues, but does not solve all of them. Also,
there are presumably millions of MIDP 1.0 devices
still in use.
Most commercial applications use device-specific build
configurations, i.e., a different version is released
for each supported device or family of devices, which
hopefully utilizes that device to the best of its
capabilities. This requires to invest
additional effort for development, testing
and maintenance.
Of course, you don't really want to do this if you are
developing for fun. Therefore, I went out of my way
to create applications which should run in any
MIDP 1.0 environment. In particular, this requires
to write a GUI which automatically layouts itself to
the device's screen size, although there will always
be a required minimum screen size. For coping
with missing functionalities, there are
different approaches:
-
Restrict your application's functionality until it
can be implemented with MIDP 1.0. This is the most
simple solution but also the least satisfying one.
-
Find some trick to implement your desired functionality
in MIDP 1.0. This is the most satisfying solution, but
often an impossible one.
-
Let your application make use of functionality outside
MIDP 1.0, but revert gracefully
if that functionality is
not supported by the device. This is rather satisfying
for non-commercial development, because it results in
an application which runs everywhere, although it
may run even better somewhere else (e.g., on MIDP 2.0
and the developers private MIDP 1.0 phone model).
Some of the fun I had with these issues was actually my main
motivation for creating this web page, and the next section lists
some tips and tricks ranging from potentially useful to
strictly hilarious.
Tips & Tricks
Some things you never wanted to know about MIDP 1.0
-
MIDP 2.0 introduced functionality for transformations
like mirroring or rotating images, and low level image
access to implement arbitrary modifications. However,
even in MIDP 1.0 it is possible to apply
arbitrary geometric transformations
to image data (although not with interpolation).
In particular, scaling images is helpful for scalable GUIs.
-
MIPD 2.0 introduced functionality for low-level access to
image pixels. However,
creating an image from pixel data in an RGB(A) array
can also be achieved with MIDP 1.0 (although the other
direction is probably impossible).
-
An application may target MIDP 1.0, but use
dynamic class loading
to load enhanced functionality using MIDP 2.0 or
a vendor-specific API extension when supported.
The same technique may be used to write MIDP 2.0 applications
supporting additional functionality on newer devices.
General hints
-
Packages, object-oriented design, and code reuse also work with MIDP!
This induces some code bloat compared to an application which only
contains functions expressly tailored to it, but if you write
applications for fun you may have a few KBs to spare and save
yourself some work instead.
-
Use an obfuscator even if you are not concerned about intellectual
property issues: It will make your application a lot smaller.
-
Only the PNG image format is guaranteed to be supported on all
devices. Although PNG compression is lossless, not every imaging
software compresses equally well. You may be able to save a few
KB simply by saving the image files with a different program.
Copyright (C) 2006-2013 by Christian Fröschlin. Please note
the legal disclaimer.
If you experience problems with this page, contact
webmaster@chrfr.de.