Java tutorial
//package com.java2s; import android.app.Activity; import android.view.WindowManager; public class Main { public static float setBrightness(float brightness, Activity a) { if (brightness < 20.0) brightness = (float) 20.0; else if (brightness > 255.0) brightness = (float) 255.0; WindowManager.LayoutParams lp = a.getWindow().getAttributes(); lp.screenBrightness = (float) (brightness / 255.0); a.getWindow().setAttributes(lp); return brightness; } }