01-03-2013 06:56 AM
Hi,
I've used NotificationsManager to fire some applicationMessages, but the notification icon do not clear (hide) after the message is read. Can you please tell me if the firing method I used is wrong?
Below is the code:
// trigger notification
NotificationEvent event = new NotificationEvent(APPLICATIONS_MESSAGES_FOLDER_ID, ++eventId, 500, -1, NotificationsConstants.MANUAL_TRIGGER);
event.fire();
event.cancel();
public final class NotificationEvent {
private long _sourceId;
long _eventId;
int _priority;
private int _triggerIndex;
private long _timeout;
// Constructor
public NotificationEvent( long sourceid, long eventid, int priority, long timeout, int triggerIndex )
{
_sourceId = sourceid;
_eventId = eventid;
_priority = priority;
_triggerIndex = triggerIndex;
_timeout = timeout;
}
/**
* Invoke the event.
*/
void fire()
{
// negotiateDeferredEvent() will cause the event to be queued.
// Ultimately, NotificationsEngineListener.proceedWithDeferredEve nt()
// will be fired in response to the event.
NotificationsManager.negotiateDeferredEvent( _sourceId, 0, this, _timeout, _triggerIndex, null );
// triggerImmediateEvent() causes non-interactable events to fire, such
// as tunes, vibrations and LED flashing as specified by the user in the
// Profiles settings. This call will cause the startNotification()
// method for all registered Consequence objects to be invoked.
// By default, the Profiles application has a Consequence registered
// and will look up the current profile's configurations to determine
// what needs to be done (in terms of vibrate and tone) for a given
// notifications source. This application's profile configuration
// appears as "Notifications Demo" in the Profiles settings.
NotificationsManager.triggerImmediateEvent( _sourceId, 0, this, null );
}
/**
* Cancel the event.
*/
void cancel()
{
// If event exists in the queue, it will be removed and
// NotificationsEngineListener.deferredEventWasSupers eded()
// will be fired.
NotificationsManager.cancelDeferredEvent( _sourceId, 0, this, _triggerIndex, null );
// The stopNotification() method for all registered Consequence objects
// will be called.
NotificationsManager.cancelImmediateEvent( _sourceId, 0, this, null );
}
}