net.rim.device.api.system
Class AccelerometerSensor.Channel

java.lang.Object
  |
  +--net.rim.device.api.system.AccelerometerSensor.Channel
Enclosing class:
AccelerometerSensor

public static class AccelerometerSensor.Channel
extends Object

Encapsulates an active connection to accelerometer sensor. While the channel remains open the sensor is queried for samples. Invoke the close() method to close the channel and stop querying the sensor in order to preserve battery power.

Since:
JDE 4.7.0

Method Summary
 void close()
          Closes the channel and stops querying the sensor.
 AccelerometerData getAccelerometerData()
          Returns the last acceleration data along with optional historical samples.
 void getLastAccelerationData(short[] xyz)
          Returns last accelerometer raw reading
 int getOrientation()
          Returns current orientation.
 boolean isActive()
          Returns if the channel is currently active and collecting requested data.
 boolean isOpen()
          Determines if the channel is open or is closed
 void removeAccelerometerListener()
          Deregisters previously assigned listener.
 void setAccelerometerListener(AccelerometerListener l)
          Registers an accelerometer listener.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public void close()
Closes the channel and stops querying the sensor. Invoke this method as soon as accelerometer data is not required in order to preserve battery power.
Since:
JDE 4.7.0

getAccelerometerData

public AccelerometerData getAccelerometerData()
                                       throws IllegalStateException
Returns the last acceleration data along with optional historical samples. The resulting data object is populated based on the channel configuration.
Throws:
IllegalStateException - if called on a closed channel
Since:
JDE 4.7.0

getLastAccelerationData

public void getLastAccelerationData(short[] xyz)
                             throws IllegalArgumentException,
                                    IllegalStateException
Returns last accelerometer raw reading
Parameters:
xyz - an allocated array of three elements to store x, y and z axis acceleration information.
Throws:
IllegalArgumentException - if passed argument is NULL, or its length is not equal to 3.
IllegalStateException - if called on a closed channel.
Since:
JDE 4.7.0

getOrientation

public int getOrientation()
                   throws IllegalStateException
Returns current orientation.
Returns:
One of the orientation constants, such as AccelerometerSensor.ORIENTATION_BACK_UP
Throws:
IllegalStateException - if called on a closed channel.
Since:
JDE 4.7.0

isActive

public boolean isActive()
Returns if the channel is currently active and collecting requested data. The channel can be inactive when the application is in background mode, and the channel was not requested to remain open in the background.
Returns:
true if channel is open and active; false otherwise.
Since:
JDE 4.7.0
See Also:
isOpen()

isOpen

public boolean isOpen()
Determines if the channel is open or is closed
Returns:
true if open; false otherwise.
Since:
JDE 4.7.0
See Also:
isActive()

removeAccelerometerListener

public void removeAccelerometerListener()
Deregisters previously assigned listener. Silently exists if there is no listener registered or channel was closed.
Since:
JDE 4.7.0

setAccelerometerListener

public void setAccelerometerListener(AccelerometerListener l)
Registers an accelerometer listener. The listener is notified on the orientation change if channel is opened for orientation, and on the accelerometer raw data change if configured for raw data. The notification is performed in the application dispatcher thread.
Parameters:
l - Listener for orientation or raw acceleration data.
Since:
JDE 4.7.0



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.