Search code examples
androidpowermanager

How to change screen brightness?


How I can change screen brightness in Android?

I can find how to do this for application, but I want do it for all system and permanently (until user changes it in options).

I don't need to set it for custom value. Just low brightness level, Medium brightness and Maximum will be perfect.

It is possible for example with PowerManager or something like that \?

Using Android 2.0+.


Solution

  • WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness = <value from 0 to 1>;
    getWindow().setAttributes(lp);