MIDP applications are built to run on many different devices without modification. This is particularly difficult in the area of user interface; MIDs have screens of all sizes, in grayscale and in color. Furthermore, the input devices on MIDs vary widely in their abilities, from numeric keypads to alphabetic keyboards, soft keys, and even touch screens. The minimum screen size mandated by the MIDP is 96 × 54 pixels, with at least one bit of color depth.[1] As for input, the MIDP is fairly open-ended: MIDs are expected to have some type of keyboard, or a touch screen, or possibly both.
Given the wide variety of devices that are compliant with the MIDP, there are two ways to create applications that work well on all MIDs:
Abstraction: Specify a user interface in abstract terms, relying on the MIDP implementation to create something concrete. Instead of saying something like, "Display the word 'Next' on the screen above soft button," you say, "Give me a Next command somewhere in this interface."
Discovery: The application learns about the device at runtime and tailors the user interface programmatically. You might, for example, find out how big the device's screen was in order to scale your user interface appropriately.
The MIDP APIs support both methods. Abstraction is the preferred method, as it involves less code in your application and more work by the MIDP implementation. In some cases, like games, you need to be more specific about user interface; these types of applications will discover the capabilities of a device and attempt to tailor their behavior appropriately. MIDP's user-interface APIs are designed so that it's easy to mix the two techniques in the same application.
[1]Color depth is the number of bits that determine the color of a pixel on the screen. One bit allows for two colors (usually black and white). Four bits allows for 16 colors, which could be different levels of gray or a palette of other colors.
Team-Fly |