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 = 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();

Was this information helpful? Send us your comments.