Issue
WindowManager.LayoutParams.screenBrightness takes a float between 0 and 1.
However, it seems that (at least on a Nexus S with Gingerbread) setting that value too low forces the screen to turn off completely.
Is there a way to know what the minimum value that can be set without having the screen turn off? Also, is this number constant across devices? If not how can we can retrieve it at runtime?
Here is some example code:
Window window = activity.getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
lp.screenBrightness = 0.01f; // float between 0 and 1
window.setAttributes(lp);
(This is for a in app brightness slider, so I need to know the minimum value to use)
Thanks
Solution
I know this is an old question, but google brought me to this post and I thought I'd share my solution. I found this today and it worked for me. I found it here: http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#BRIGHTNESS_OVERRIDE_OFF
Example:
Window MyWindow = getWindow();
WindowManager.LayoutParams winParams = MyWindow.getAttributes();
winParams.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
MyWindow.setAttributes(winParams);
I hope this helps.
Answered By - T3chDad