Class ScreenBrightness

java.lang.Object
com.codename1.system.ScreenBrightness

public final class ScreenBrightness extends Object

The application window's screen brightness, and keeping the screen on.

The brightness applies to this application's window only and needs no permission. Call #reset() to hand control back to the system setting.

if (ScreenBrightness.isSupported()) {
    ScreenBrightness.set(1f);
}
ScreenBrightness.setKeepScreenOn(true);
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    get()
    The window brightness from 0 to 1, or a negative value when the window follows the system brightness or the platform cannot tell.
    static boolean
    True when the port can change the window brightness.
    static void
    Returns the window to the system brightness.
    static boolean
    set(float level)
    Sets the window brightness.
    static void
    setImplementation(com.codename1.impl.CodenameOneImplementation impl)
    Invoked internally from Display, this method is for internal use only
    static void
    setKeepScreenOn(boolean on)
    Keeps the screen on while the application is in the foreground.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 port can change the window brightness.

      Returns

      true when #set(float) has an effect

    • get

      public static float get()

      The window brightness from 0 to 1, or a negative value when the window follows the system brightness or the platform cannot tell.

      Returns

      the brightness or a negative value

    • set

      public static boolean set(float level)

      Sets the window brightness.

      Parameters
      • level: the brightness from 0 to 1; it is clamped to that range
      Returns

      true when the platform applied it

    • reset

      public static void reset()
      Returns the window to the system brightness.
    • setKeepScreenOn

      public static void setKeepScreenOn(boolean on)

      Keeps the screen on while the application is in the foreground. This is Display#setScreenSaverEnabled(boolean) under a clearer name.

      Parameters
      • on: true to keep the screen on