In Android 2.3.3, I'm trying to set the screen brightness to 0 with this code:
Window myWindow = getWindow();
WindowManager.LayoutParams winParams = myWindow.getAttributes();
winParams.screenBrightness = 0.0f;
myWindow.setAttributes(winParams);
and scheduling a Handler.postDelayed() to launch a Runnable in 1 sec to set the brightness back to full like this:
Window myWindow = getWindow();
WindowManager.LayoutParams winParams = myWindow.getAttributes();
winParams.screenBrightness = 1.0f;
myWindow.setAttributes(winParams);
However, the screen seems to be completely off and nothing happens after this 1 sec. Putting some trace into the Runnable clearly shows that it is launched by Handler.
I've also tried enclosing these two calls into a PARTIAL_WAKE_LOCK, with no result. Anyway, the Runnable works, so not much use of wake locks here.
Also, if the brightness set to 0.01f not to 0f, it works fine - after 1 sec it goes back to full.
Could anyone please advise how to make the brightness go back to full again after setting it to 0?