How do you get the current screen brightness of your activity?
Following method works fine for setting the brightness to max by calling setBrightness(100)
:
private void setBrightness(int brightness) {
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = brightness/100.0f;
getWindow().setAttributes(layoutParams);
}
Im trying to achieve the following:
Many thanks!
Anything around 600 nits is good enough, but there are smartphones that push the brightness to over 1000 nits. Too low brightness or going for too high brightness is very dangerous for eyes.
Adaptive brightness gives your phone the ability to adjust the screen brightness automatically depending on the amount of light around you. The setting is typically on by default, but it's easy to turn off if you want to. Swipe down from the top of the screen to reveal the Notification Shade.
To get the brightness of a screen use the getint() method that returns the current brightness of a system. You will the brightness to the setProgress() method as an argument. Now set the seekbar on setOnSeekBarChangeListener() to change the brightness of a screen.
Adaptive Brightness helps your phone to learn your preferred screen brightness in different lighting. Your phone's screen brightness will be automatically set for you.
Try
int curBrightnessValue = android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
and then
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = curBrightnessValue/100.0f;
getWindow().setAttributes(layoutParams);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With