net.rim.device.api.system
Class Sensor

java.lang.Object
  |
  +--net.rim.device.api.system.Sensor

public final class Sensor
extends Object

API's to determine the existence and states of device sensors.

Since:
JDE 4.6.0

Field Summary
static int FLIP
          Sensor ID of the flip sensor.
static int HOLSTER
          Sensor ID of the holster sensor.
static int STATE_FLIP_CLOSED
          A state of the flip sensor that indicates the BlackBerry device flip is closed.
static int STATE_FLIP_OPEN
          A state of the flip sensor that indicates the BlackBerry device flip is open.
static int STATE_IN_HOLSTER
          A state of the holster sensor that indicates the BlackBerry device is in the holster.
static int STATE_OUT_OF_HOLSTER
          A state of the holster sensor that indicates the BlackBerry device is not in the holster.
 
Method Summary
static void addListener(Application app, SensorListener listener, int sensors)
          Adds a listener that listens for changes to the state of device sensors.
static int getState(int sensorId)
          Return the last known state of a sensor.
static boolean isSupported(int sensorId)
          Determines if the BlackBerry device supports a specific sensor.
static void removeListener(Application app, SensorListener listener)
          Removes a listener from the provided application's list of listeners.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FLIP

public static final int FLIP
Sensor ID of the flip sensor. Corresponds to a bit.
Since:
JDE 4.6.0

HOLSTER

public static final int HOLSTER
Sensor ID of the holster sensor. Corresponds to a bit.
Since:
JDE 4.6.0

STATE_FLIP_CLOSED

public static final int STATE_FLIP_CLOSED
A state of the flip sensor that indicates the BlackBerry device flip is closed.
Since:
JDE 4.6.0

STATE_FLIP_OPEN

public static final int STATE_FLIP_OPEN
A state of the flip sensor that indicates the BlackBerry device flip is open.
Since:
JDE 4.6.0

STATE_IN_HOLSTER

public static final int STATE_IN_HOLSTER
A state of the holster sensor that indicates the BlackBerry device is in the holster.
Since:
JDE 4.6.0

STATE_OUT_OF_HOLSTER

public static final int STATE_OUT_OF_HOLSTER
A state of the holster sensor that indicates the BlackBerry device is not in the holster.
Since:
JDE 4.6.0
Method Detail

addListener

public static void addListener(Application app,
                               SensorListener listener,
                               int sensors)
Adds a listener that listens for changes to the state of device sensors. The event thread of the provided application processes the notifications. If the application has already registered this listener, invoking this method overrides the previous invocations.
Parameters:
app - The application that processes the listener notifications.
listener - An instance of SensorListener to receive changes to the state of device sensors.
sensors - A bitwise OR of sensor ID's.
Throws:
NullPointerException - If listener or app is null.
Since:
JDE 4.6.0

getState

public static int getState(int sensorId)
Return the last known state of a sensor.
Parameters:
sensorId - The ID of sensor
Returns:
the last known state of the given sensor
Throws:
IllegalArgumentException - If sensorId does not represent a supported sensor
Since:
JDE 4.6.0

isSupported

public static boolean isSupported(int sensorId)
Determines if the BlackBerry device supports a specific sensor.
Parameters:
sensorId - The ID of a sensor to query.
Returns:
true if the sensor is present; false otherwise.
Since:
JDE 4.6.0

removeListener

public static void removeListener(Application app,
                                  SensorListener listener)
Removes a listener from the provided application's list of listeners. If listener is null or is not on the provided application's list of listeners, then this method does nothing.
Parameters:
app - The application that registered this listener.
listener - An instance of SensorListener to stop receiving changes to the state of device sensors.
Throws:
NullPointerException - if app is null.
Since:
JDE 4.6.0



Copyright 1999-2008 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.