I need to change Android Screen brightness through my app. All the existing answers I've seen are related to window screen brightness but I need device brightness.
-
I think the OP wants to actually make the screen brighter/dimmer, not only change the reported value of the brightness. – Shivan Dragon Feb 27 '12 at 14:33
2 Answers
To change device settings for brightness you'll need to do this:
android.provider.Settings.System.putInt(getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS, brightness);
Where brightness
must be an integer between 0 and 255. Remember, however, that setting screen brightness to 0 will turn the screen off and turning it back on will not be easy. So always check that brightness is >0 (i personally set minimum brightness to 10).
Let me know if you have further questions.

- 5,719
- 6
- 43
- 80
-
Why this piece of codes cause my app stopped expectedly? On Android 4.1 simulator. – JackWM Feb 24 '13 at 02:47
According to my experience
1st method.
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 75 / 100.0f;
getWindow().setAttributes(lp);
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
2nd method.
android.provider.Settings.System.putInt(getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS, 192);
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.
if(arg2==1)
{
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 75 / 100.0f;
getWindow().setAttributes(lp);
android.provider.Settings.System.putInt(getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS, 192);
}
It worked properly for me

- 727
- 1
- 7
- 19