Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class ScreenBrightness
- Object
- 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
implCodenameOneImplementation- implementation instance
isSupported
public static boolean isSupported()True when the port can change the window brightness.
Returns
true when
#set(float) has an effectget
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
levelfloat- 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
onboolean- true to keep the screen on