Android examples for android.provider:Settings
set Window Brightness
import android.app.Activity; import android.view.Window; import android.view.WindowManager; public class Main { public static void setWindowBrightness(Activity activity, float screenBrightness) { float brightness = screenBrightness; if (screenBrightness < 1) { brightness = 1;/* w w w.ja v a2 s. c om*/ } else if (screenBrightness > 255) { brightness = screenBrightness % 255; if (brightness == 0) { brightness = 255; } } Window window = activity.getWindow(); WindowManager.LayoutParams localLayoutParams = window.getAttributes(); localLayoutParams.screenBrightness = (float) brightness / 255; window.setAttributes(localLayoutParams); } }