Mobile Sensor API Version 1.2

javax.microedition.sensor
Interface SensorListener


public interface SensorListener

The SensorListener represents a listener that receives notifications when the availability of the sensor changes. Classes implementing the SensorListener interface receive following notifications:

In addition to changes in availability, after registration of the SensorListener, either of these notifications is sent to the application based on the availability at that point.

Availability does not mean the same as opened, but that the access to the sensor is possible. In the case of the sensor working via a serial cable, it means that the sensor is now plugged in. In the case of the sensor working over Bluetooth it means that the sensor has come within the proximity of the device. The application must implement this interface and register itself to the SensorManager to obtain the sensor availability updates. To stop getting availability notifications the application must remove the registration with the method SensorManager.removeSensorListener().

The application is responsible for any possible synchronization required in the listener methods. The listener methods MUST return quickly and should not perform any extensive processing. The method calls are intended as triggers for the application. The application should do all necessary extensive processing in a separate thread and only use these methods to initiate the processing.


Method Summary
 void sensorAvailable(SensorInfo info)
          The notification called when the sensor becomes available.
 void sensorUnavailable(SensorInfo info)
          The notification called when the sensor becomes unavailable.
 

Method Detail

sensorAvailable

void sensorAvailable(SensorInfo info)

The notification called when the sensor becomes available. The notification is also called immediately if the sensor is already available when adding the listener.

Parameters:
info - the SensorInfo object indicating which sensor is now available

sensorUnavailable

void sensorUnavailable(SensorInfo info)

The notification called when the sensor becomes unavailable. The notification is also called immediately if the sensor is already unavailable when adding the listener.

Parameters:
info - the SensorInfo object indicating which sensor is now unavailable

Mobile Sensor API Version 1.2

Copyright © 2005-2008 Nokia Corporation. All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.