The code below to change screen brightness is not working when auto brightness of device is enabled:
Window w = getWindow();
WindowManager.LayoutParams lp = w.getAttributes();
lp.screenBrightness=0.09f;
getWindow().setAttributes(lp);
How to change this code for working on auto brightness too?
DISCLAIMER: This code is kind of 'hackish', and might not work on all android versions and all android phones, and might not be the best code practice. I claim no responsibility if your device explodes, or it starts raining etc. :)
That being said, you might want to disable autobrightness temporarily:
And then re-enable it: