I use this simple code to set the SCREEN_BRIGHTNESS at System level in Android (not just for my app):
android.provider.Settings.System.putInt(MyContext.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
android.provider.Settings.System.putInt(MyContext.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS, MyValue);
According to docs values can be from 0 to 255.
But I get strange results as displayed in the Android settings or on the notification panel where you can see the screen brightness slider.
If I set MyValue to 0, it works correctly. The screen brightness is set to the minimum. Good.
Also, if I set MyValue to 255, it works correctly. The screen brightness is set to the maximum. Good.
Problems start if I set other values, like a 50% (which is 255/2=128). In this case the screen brightness is not set to 50%, it is something like 90%.
If I set it to 25% (which is 255/4=56), the screen brightness is not set to 25%, it is something like 70%.
If I set it to 10% (which is 255/10=26), the screen brightness is not set to 10%, it is something like 40%.
I think I am missing something here. Any help?
What I have tried:
I have tried in emulator and real devices