This example MIDlet shows you how to use sensor data. The MIDlet demonstrates the basics of sensor operation, such as opening a sensor connection, listening to sensor values, and closing a sensor connection.
The ArrowKeys MIDlet receives sensor data from the accelerometer sensor, and translates it to key press events and a visual indicator. The accelerometer-to-key-press functionality can be replicated in other MIDlets to, for example, control an object on the screen. From the MIDlet perspective, the sensors function only as data sources. This means that it is a straightforward task to incorporate features, such as the orientation detection described in this example, to legacy MIDlets.
The accelerometer sensor returns the state of the mobile device's rotation in three axes: x, y, z. The ArrowKeys MIDlet uses these return values to determine the orientation and rotation of the device.
Figure: ArrowKeys MIDlet
You need the following to develop and test this MIDlet:
Nokia SDK 2.0 for Java SDK or newer
Java Runtime 2.0.0 for Series 40 device or newer
For instructions on how to get started with Java ME, see section Getting started.
For more information about the MIDlet, see:
Design for information about the design and functionality of the MIDlet
Implementation for instructions on how to implement the MIDlet
You can download the project files for the MIDlet from the download page.