tags:

views:

94

answers:

2

hi all. i want to change the screen brightness programmatically in android.

WindowManager.LayoutParams lp = getWindow().getAttributes();
float brightness=1.0f;
lp.screenBrightness = brightness;
getWindow().setAttributes(lp);

But this sample code works on cutcake, not on latest versions. I am using latest version of SDK.. how can i do it..?please let me know..thanks in advance.

A: 

How about using the IHardwareService interface for this? An example can be found in this tutorial.

Maurits Rijk
Wow, an accepted answer * and * a down vote. Maybe the voter would care to explain why he did so?
Maurits Rijk
A: 

This is possible to do by using:

WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.screenBrightness = 1F;
getWindow().setAttributes(layout);

See also: http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#screenBrightness

Dipper