Skip to main content

Destroying or Replacing a Notification

Destroying a Notification

Use the destroyNotification() method to remove a notification that is visible. When this method is invoked, the notification that is currently displayed is discarded and the next notification that is in the queue is displayed immediately. The destroyNotification() method requires the value in uniqueId that the createNotification() method returns. The destroyNotification() method must also be invoked in the SWT UI thread. You cannot use the unique ID that is associated with the notification again.

The following sample code shows the destroyNotification() method.

  String uniqueId = service.createNotification(notification);

Replacing a Notification

After a notification is visible for the amount of time that you define, use the replaceNotification() method to replace the notification with a new one. This method requires the uniqueId of the original notification. After replacement of the notification, the replaceNotification() method changes and returns the uniqueId.

The following sample code shows the replaceNotification() method.

  String uniqueId = service.createNotification(notification);
  String newUniqueId = service.replaceNotification(uniqueId, newNotification);