Class ScreenBrightness
java.lang.Object
com.codename1.system.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);
-
Method Summary
Modifier and TypeMethodDescriptionstatic floatget()The window brightness from 0 to 1, or a negative value when the window follows the system brightness or the platform cannot tell.static booleanTrue when the port can change the window brightness.static voidreset()Returns the window to the system brightness.static booleanset(float level) Sets the window brightness.static voidsetImplementation(com.codename1.impl.CodenameOneImplementation impl) Invoked internally from Display, this method is for internal use onlystatic voidsetKeepScreenOn(boolean on) Keeps the screen on while the application is in the foreground.
-
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
-