net.rim.device.api.system
Class Sensor

java.lang.Object
  extended by net.rim.device.api.system.Sensor

public final class Sensor
extends Object

Determines the existence and states of device sensors.

Since:
BlackBerry API 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 SLIDE
          Sensor ID of the slider sensor.
static int STATE_FLIP_CLOSED
          A state of the flip sensor that indicates that the BlackBerry device flip is closed.
static int STATE_FLIP_OPEN
          A state of the flip sensor that indicates that the BlackBerry device flip is open.
static int STATE_IN_HOLSTER
          A state of the holster sensor that indicates that the BlackBerry device is in the holster.
static int STATE_OUT_OF_HOLSTER
          A state of the holster sensor that indicates that the BlackBerry device is not in the holster.
static int STATE_SLIDE_CLOSED
          A state of the slide sensor that indicates that the BlackBerry device slider is closed.
static int STATE_SLIDE_IN_TRANSITION
          A state of the slider sensor that indicates that the BlackBerry device slider is in transition between the open and closed states.
static int STATE_SLIDE_OPEN
          A state of the slide sensor that indicates that the BlackBerry device slider is open.
 
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)
          Returns the last known state of a sensor.
static boolean isSupported(int sensorId)
          Returns whether or not 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

HOLSTER

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

See Also:
Constant Field Values
Since:
BlackBerry API 4.6.0

FLIP

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

See Also:
Constant Field Values
Since:
BlackBerry API 4.6.0

SLIDE

public static final int SLIDE
Sensor ID of the slider sensor. Corresponds to a bit.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

STATE_OUT_OF_HOLSTER

public static final int STATE_OUT_OF_HOLSTER
A state of the holster sensor that indicates that the BlackBerry device is not in the holster.

See Also:
Constant Field Values
Since:
BlackBerry API 4.6.0

STATE_IN_HOLSTER

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

See Also:
Constant Field Values
Since:
BlackBerry API 4.6.0

STATE_FLIP_OPEN

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

See Also:
Constant Field Values
Since:
BlackBerry API 4.6.0

STATE_FLIP_CLOSED

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

See Also:
Constant Field Values
Since:
BlackBerry API 4.6.0

STATE_SLIDE_OPEN

public static final int STATE_SLIDE_OPEN
A state of the slide sensor that indicates that the BlackBerry device slider is open.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

STATE_SLIDE_CLOSED

public static final int STATE_SLIDE_CLOSED
A state of the slide sensor that indicates that the BlackBerry device slider is closed.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

STATE_SLIDE_IN_TRANSITION

public static final int STATE_SLIDE_IN_TRANSITION
A state of the slider sensor that indicates that the BlackBerry device slider is in transition between the open and closed states.

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0


Method Detail

isSupported

public static boolean isSupported(int sensorId)
Returns whether or not the BlackBerry device supports a specific sensor.

Parameters:
sensorId - The ID of a sensor. One of Sensor.HOLSTER, Sensor.FLIP, or Sensor.SLIDE.
Returns:
true if the sensor is present; false otherwise.
Since:
BlackBerry API 4.6.0

getState

public static int getState(int sensorId)
Returns the last known state of a sensor.

Parameters:
sensorId - The ID of a sensor. One of Sensor.HOLSTER, Sensor.FLIP, or Sensor.SLIDE.
Returns:
the last known state of the given sensor
Throws:
IllegalArgumentException - If sensorId does not represent a supported sensor
Since:
BlackBerry API 4.6.0

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 invocation.

Parameters:
app - The Application that processes the listener notifications.
listener - The SensorListener to receive changes to the state of device sensors.
sensors - A bitwise OR of sensor IDs.
Throws:
NullPointerException - If listener or app is null.
Since:
BlackBerry API 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, this method does nothing.

Parameters:
app - The Application that registered this listener.
listener - The SensorListener to stop receiving changes to the state of device sensors.
Throws:
NullPointerException - if app is null.
Since:
BlackBerry API 4.6.0





Copyright 1999-2010 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. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.