Mobile Sensor API Version 1.2

javax.microedition.sensor
Interface DataListener

All Known Subinterfaces:
DataAndErrorListener

public interface DataListener

The DataListener interface is implemented by the application to receive data from the sensor. The application must implement this interface and register itself as a listener with the method SensorConnection.setDataListener() to obtain dataReceived() notifications. To quit getting notifications, the application must call the method SensorConnection.removeDataListener(). dataReceived() notifications MUST NOT be sent to the application after the connection to the listened sensor is closed. This data retrieval mode is called asynchronous and is separate from the synchronous mode, where the application thread requests the data and waits for the results to be returned.

The implementation MUST guarantee that only one thread calls the dataReceived() method at a time. The application is responsible for any possible synchronization needed 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 any necessary extensive processing in a separate thread and only use these methods to initiate the processing.

Some data may be lost if the dataReceived method does not return fast enough. The parameter isDataLost of the dataReceived() method is used to inform the application of the data loss.


Method Summary
 void dataReceived(SensorConnection sensor, Data[] data, boolean isDataLost)
          Notification of the received sensor data.
 

Method Detail

dataReceived

void dataReceived(SensorConnection sensor,
                  Data[] data,
                  boolean isDataLost)

Notification of the received sensor data.

Parameters:
sensor - SensorConnection, the origin of the received data
data - the received sensor data, Data objects of all the channels of the sensor. The size of the Data object array equals the number of the channels.
isDataLost - true if some data has been lost between the previously delivered data and the beginning of the data returned in this method call. The data loss is a result of previous listener calls not having returned quickly enough for the next data to be delivered. The value of this parameter should be false normally when the listener handles the data quickly.

Mobile Sensor API Version 1.2

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