Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class ScreenBrightness

  1. Object
  2. ScreenBrightness

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);

Methods

public static void setImplementation(CodenameOneImplementation impl)Invoked internally from Display, this method is for internal use only
public static boolean isSupported()True when the port can change the window brightness.
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.
public static boolean set(float level)Sets the window brightness.
public static void reset()Returns the window to the system brightness.
public static void setKeepScreenOn(boolean on)Keeps the screen on while the application is in the foreground.

Inherited methods

Method details

setImplementation

public static void setImplementation(CodenameOneImplementation impl)
Invoked internally from Display, this method is for internal use only

Parameters

impl CodenameOneImplementation
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 float
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 boolean
true to keep the screen on