Would you like to tell us how we are doing?

You bet No thanks

Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Notifications sample app

The notifications sample application demonstrates how to define, start, and stop notification events on a BlackBerry device. Notifications include either hardware-driven notifications (such as a flashing LED light, a vibration, or a tone), software UI driven notifications, (such as a dialog box), or both.

The sample application demonstrates how to register the application as a notifications event provider with the BlackBerry device, how to define what notification events are started when the event occurs, and how to start and stop the notification.

File name

Description

ConsequenceImpl.java

  • the Consequence interface implementation
  • contains the SyncObject and SyncConverter interface implementations as required by the Consequence interface

Event.java

class that contains the attributes of the notification event and the methods to start and stop the notification event

NotificationsDemo.java

  • the entry point for the application
  • contains the main method, which registers the application as a notification event source when the BlackBerry device starts
  • contains the application's Screen class which contains a menu item to start the notification event

NotificationsEngineListenerImpl.java

the implementation of the NotificationsEngineListener interface which contains methods that manage the UI components that are displayed when notification events start and stop

This sample features the following classes:

net.rim.device.api.notification.NotificationsManager

This class provides methods to manage the handling of events between applications and the notification engine, the registration of NotificationsEngineListener and Consequence interface implementations, and the registration of applications as sources of notification events.

In the registerNotificationObject() method of the NotificationDemo class, the sample application uses the NotificationManager class to register the sample application as a source of notification events, the NotificationEngineListenerImpl class as the NotificationEngineListener implementation of the NotificationDemo class, and the ConsequenceImpl class as the Consequence implementation of the NotificationDemo class.

The sample application also uses this class to start and stop notification events in the Event class' fire() and cancel() methods respectively.

net.rim.device.api.system.Alert

This class provides methods to access the BlackBerry device's audio features. You can use these methods to check which audio features are supported, to set the master volume or the volumes of each distinct audio type, and to start and stop the sound from each audio source.

The sample application uses this class to start the buzzer and music when a notification event starts and to stop the buzzer and music when a notification event stops.

net.rim.device.api.system.LED

This class provides methods to access the BlackBerry device's LED light. You can use these methods to check which features of the LED light are supported and to set the state of the LED notification light with a specific configuration.

The sample application uses this class to set the LED notification light to on when a notification event starts and to set the LED notification light to off when a notification event stops.

Install the sample app

Visit http://www.blackberry.com/go/notificationssample to download the sample application.

Extract the notificationsdemo.zip file.

On the taskbar, click Start > Programs > Research In Motion > BlackBerry JDE 4.7.0 > JDE.

Open the workspace that you want to add the sample application to.

In the workspace tree, right-click the project that you want to add the sample application to.

Click Add project to <workspace directory>.

In the Add project to <workspace> dialog box, browse to the folder where you extracted the sample application.

Click the NotificationsDemo.jdp file.

Click Open.

The sample is also available in github.

Run the sample app

In the workspace where you added the svganimator demo project, right-click notificationsdemo.

Click Build project.

On the taskbar, click Start > Applications > Research in Motion > BlackBerry JDE 4.7.0 > Device Simulator.

On the Home screen of the BlackBerry Smartphone Simulator, click the Downloads folder.

Click the Notifications Demo icon.