4.
Invoke
AccelerometerSensor.openChannel()
to open a channel to the accelerometer.
Channel bufferedChannel = AccelerometerSensor.openChannel
( Application.getApplication(), channelConfig );
Retrieve accelerometer readings from a buffer
1.
Import the following classes:
•
net.rim.device.api.system.AccelerometerData;
•
net.rim.device.api.system.AccelerometerSensor.Channel;
2.
Query the buffer for accelerometer data.
AccelerometerData accData;
accData = bufferedChannel.getAccelerometerData();
3.
Invoke
AccelerometerData.getNewBatchLength(),
to get the number of readings retrieved since the last
query.
int newBatchSize = accData.getNewBatchLength();
4.
Invoke
AccelerometerData.getXAccHistory()
,
AccelerometerData.getYAccHistory()
,
and
AccelerometerData.getZAccHistory(),
to retrieve accelerometer data from the buffer for each axis.
short[] xAccel = accData.getXAccHistory();
short[] yAccel = accData.getYAccHistory();
short[] zAccel = accData.getZAccHistory();
Get the time a reading was taken from the accelerometer
1.
Import the
net.rim.device.api.system.AccelerometerData
class.
2.
Query the buffer for accelerometer data.
AccelerometerData accData;
accData = bufferedChannel.getAccelerometerData();
3.
Invoke
AccelerometerData.getSampleTsHistory()
.
long[] queryTimestamps = accData.getSampleTsHistory();
UI components
Add a UI component to a screen
1.
Import the following classes:
•
net.rim.device.api.ui.component.CheckboxField
•
net.rim.device.api.ui.container.MainScreen
2.
Create an instance of a UI component.
Development Guide
UI components
15