x += field.getPreferredWidth();
y += field.getPreferredHeight();
}
setExtent(width,height);
}
Working with the accelerometer of a BlackBerry device
On a BlackBerry® device with an accelerometer, you can create a BlackBerry device application that listens for accelerometer
events and retrieves data about the orientation of the BlackBerry device.
The BlackBerry OS converts accelerometer readings into orientation coordinates such as
TOP_UP
,
FACE_UP
, and
LEFT_UP
. The BlackBerry OS may also rotate the screen in response to accelerometer readings.
Querying the accelerometer consumes battery power. Connections to the accelerometer should not be kept open for long periods
of time.
Types of accelerometer data
A BlackBerry® device application can retrieve data from the accelerometer.
Data type
Description
orientation
The orientation of the BlackBerry device with respect to the ground.
acceleration
The acceleration of the rotation of the BlackBerry device.
For more information about types of data from the accelerometer, see the API reference for the BlackBerry® Java® Development
Environment
Accelerometer
The BlackBerry® Storm device includes an acclerometer that senses the orientation and acceleration of the device. When a
BlackBerry device user moves the device, the accelerometer senses the movement in 3-D space along the x, y, and z axis. A
BlackBerry device user can change the orientation of the device which can change the display direction of a screen for a BlackBerry
device application between portrait and landscape.
The Accelerometer APIs in the
net.rim.device.api.system
package let a BlackBerry device application respond to
the orientation and acceleration of a BlackBerry device. For example, you can manipulate a game application to change the
direction and speed of a moving object on the screen as a BlackBerry device user moves and rotates the BlackBerry device at
different speeds.
Development Guide
Working with the accelerometer of a BlackBerry device
12