Overview
Many applications require the ability to alert a BlackBerry® smartphone user that an event occurred. This could be achieved by playing an audio alert, vibrating or flashing the LED. Many developers attempt to manually trigger these alerts from within their application but with only a few lines of code an application is able to integrate with and appear within the Notification/Profiles application of a BlackBerry Smartphone. This type of implementation provides a number of benefits to the developer and the end user:
It also benefits the developer in that the application does not need to implement the code to provide a GUI for the user to choose their type of alert, store their alert options or to trigger the chosen alert.
Implementation
The first step in using this type of notification is to register your application with the Notification/Profiles application.
// Long value com.samples.simpleNotification
private static final long ID = 0x749cb23a75c60e2dL;
//The toString value of this object will be displayed in the user's Profile settings.
Object theSource = new Object()
{
public String toString()
{
return "Simple Notification";
}
};
//Register the notification.
NotificationsManager.registerSource(ID, theSource, NotificationsConstants.IMPORTANT);
Once registered, an application is able to trigger the alert the user has configured.
NotificationsManager.triggerImmediateEvent(ID, 0, null, null);
A complete sample application is attached.