Mobile Sensor API Version 1.2

Interface ConditionListener

public interface ConditionListener

An interface implemented by the application to receive notifications when the monitored data meets the condition defined by the application. The application has to implement the ConditionListener interface and add Condition objects to Channel objects to be monitored. Added Condition objects are checked against each data value of the channel. All the registered listeners having their Condition objects met MUST be called in a reasonable time.

A conditionMet() notification is sent for each condition that the measured data value meets. Thus, there may be several notifications for one measured value. Once a data value meets the condition and the notification is sent, this Condition is removed from the Channel. The Condition is removed in order to prevent the application from getting flooded with notifications, because it is quite likely that many successive measurement values would meet the condition. It is the responsibility of the application to determine when to add the condition back, if necessary.

A conditionMet() notification may be also used to inform about a met push condition. When the application is automatically launched because of the met condition, the AMS will store the corresponding data value and condition. When the application registers itself as a ConditionListener, the pending information as the conditionMet() notification is sent to the application. For more information see Appendix C "Automatic Launch".

The notification returns three parameters:

  1. SensorConnection which sent the notification. The application can register to listen to many sensors and this parameter lets the application know which sensor caused this notification.
  2. Data object with one value. The object contains the data value, which met the Condition, the timestamp, the uncertainty, the ChannelInfo object, and the validity. The validity MUST always be true
  3. Condition which was met

The implementation MUST guarantee that the implementation threads call conditionMet() sequentially, one after the other. 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.

Method Summary
 void conditionMet(SensorConnection sensor, Data data, Condition condition)
          Notifies the application that a measured value from a sensor has met the defined Condition.

Method Detail


void conditionMet(SensorConnection sensor,
                  Data data,
                  Condition condition)

Notifies the application that a measured value from a sensor has met the defined Condition.

sensor - SensorConnection, from where the data was retrieved
data - the Data object which contains the met value, the timestamp, the uncertainty, and the validity
condition - Condition which was met. If the application wants to continue to monitor the same Condition, the returned Condition may be registered again at a suitable point in time.

Mobile Sensor API Version 1.2

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