Class DesktopNotifications

java.lang.Object
com.codename1.desktop.DesktopNotifications

public final class DesktopNotifications extends Object

Shows a native desktop notification now. It is a shortcut over LocalNotification: the notification goes through the same port path, and a click on it reaches the application's LocalNotificationCallback with the identifier given here. Mobile platforms answer false from #isSupported(); LocalNotification itself still works there.

if (DesktopNotifications.isSupported()) {
    DesktopNotifications.show("build-done", "Build finished", "All tests passed");
}
  • Method Details

    • setImplementation

      public static void setImplementation(com.codename1.impl.CodenameOneImplementation impl)

      Invoked internally from Display, this method is for internal use only

      Parameters
      • impl: implementation instance
    • isSupported

      public static boolean isSupported()

      True when the platform shows native desktop notifications.

      Returns

      true on a desktop platform with notifications

    • show

      public static LocalNotification show(String id, String title, String body)

      Shows a notification now.

      Parameters
      • id: the identifier the click callback receives
      • title: the title
      • body: the body text
      Returns

      the notification that was scheduled, or null when not supported

    • dismiss

      public static void dismiss(String id)

      Removes a notification shown by #show(String, String, String).

      Parameters
      • id: its identifier