Use net.rim.device.api.notification.NotificationsManag er
Call registerNotificationObjects() once on device start up, call triggerNotification() when you want to alert the user. The type of alert can be selected by the user through the profile selection and editing interface. The application will have to be compiled to Auto-run on startup.
Code:
...
private static final long MY_NOTIFICATION = 0x71a090a90bdcee80L; // A unique value
private static final String MY_NOTIFICATION_NAME = "My Notification";
private static long eventId = 0;
...
// Register notification object
private void registerNotificationObjects()
{
//New Notifications Sources - these will show up as editable configurations in the Profiles application
NotificationsManager.registerSource( MY_NOTIFICATION,
new Object()
{
public String toString()
{
return MY_NOTIFICATION_NAME;
}
}
, NotificationsConstants.IMPORTANT
);
}
private void triggerNotification()
{
int trigger = NotificationsConstants.MANUAL_TRIGGER;
long timeout = -1; //the timeout parameter is IGNORED unless the TRIGGER is OUT_OF_HOLSTER_TRIGGER
NotificationsManager.triggerImmediateEvent( MY_NOTIFICATION, eventId++, this, null);
}