I want to change the system brightness programmatically. For that purpose I am using this code:
WindowManager.LayoutParams lp = window.getAttributes();
lp.screenBrightness = (255);
window.setAttributes(lp);
because I heard that max value is 255.
but it does nothing. Please suggest any thing that can change the brightness. Thanks
This is the complete code on how to change system brightness
Or you may check this tutorial for complete code
happy coding:)
This worked for me. No need of a dummy activity. This works only for your current activity.
Reference link
Please Try this , it's May help you. Worked fine for me
According to my experience
where the brightness value very according to 1.0f.100f is maximum brightness.
The above mentioned code will increase the brightness of the current window. If we want to increase the brightness of the entire android device this code is not enough, for that we need to use
Where 192 is the brightness value which very from 1 to 255. The main problem of using 2nd method is it will show the brightness in increased form in android device but actually it will fail to increase android device brightness.This is because it need some refreshing.
That is why I find out the solution by using both codes together.
It worked properly for me
this worked for me till kitkat 4.4 but not in android L
You can use following :
In your onCreate write:
Write the code to monitor the change in brightness.
then you can set the updated brightness as follows:
Permission in manifest:
For API > 23, you need to request the permission through Settings Activity, described here: Can't get WRITE_SETTINGS permission