Retrieve Accelerometer Readings From A Buffer; Get The Time A Reading Was Taken From The Accelerometer; Ui Components; Add A Ui Component To A Screen - Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE Manual

Version: 4.7.0
Hide thumbs Also See for JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE:
Table of Contents

Advertisement

Development Guide
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.
UI components
15

Advertisement

Table of Contents
loading

This manual is also suitable for:

Java development environment

Table of Contents