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:
- Start the activity and save the current brightness value
- Set brightness to max
- Reset brightness to the initial value on certain events
Many thanks!
Try
and then