Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the screen brightness to the minimum

I have problems trying to set the screen brightness to the minimum. My code is the following:

        WindowManager.LayoutParams params = w.getAttributes();
        params.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
        w.setAttributes(params);

The problem is that the screen turns off completely in some devices and it is almost impossible to turn the screen on again even pressing the power button (fortunately the screen turns on again after a while). I have no idea about this behavior.

Help please. Thanks in advance.

Fran.

like image 420
francas Avatar asked Sep 01 '25 22:09

francas


1 Answers

Try this,

WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.screenBrightness = 1F;
getWindow().setAttributes(layout);

And also check the Official Documentation Screen Brightness

try change the values with 0.1 precision in layout.screenBrightness = 0.1F or 0.2F and so on.

I hope this helps your needs.

like image 117
Punith K Avatar answered Sep 03 '25 16:09

Punith K