Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

General Open Source Topics

Reply
New Contributor
alxArad
Posts: 4
Registered: ‎12-27-2012
My Carrier: AT&T

Use of NotificationsManager

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.proceedWithDeferredEvent()
            // 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.deferredEventWasSuperseded()
            // 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 );
        }

}

 

Please use plain text.