WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.screenBrightness = 100 / 100.0f; getWindow().setAttributes(lp);
References:
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#screenBrightness
http://groups.google.com/group/android-developers/browse_thread/thread/6de1cb84596a1c9b
Update History
Jan 17, 2012 - Visual Update
6 comments:
[...] Mendoza - Changing the Screen Brightness Programatically by bakhtiyor | Categories: Uncategorized | Enjoyed this article? Subscribe to the full RSS [...]
How do you make it work in a widget since getWindow() isn't gonna work?
I would like to know how to do this from a widget as well.
Well this only changes the current activity,not the entire system..Do you know how to change the brightness level for the cellphone?
OK,I figure it out myself.All you have to do is start up an activity,shows a button.When you click that button,write the system settings,which is "screen_brightness" or sth.Then you use the method in this post to actually change it.After doing these,you can leave your activty,and the brightness level remains.
to MorrisLiang:
It does work on 1.5 virtual machine, but sadly it does not work on my Hero :( I am trying to figure out, any ideas would help me a lot. Thx.
Post a Comment