Java tutorial
//package com.java2s; //License from project: LGPL import android.app.Activity; import android.view.WindowManager; public class Main { public static void setBrightness(Activity activity, float brightness) { // Settings.System.putInt(activity.getContentResolver(), // Settings.System.SCREEN_BRIGHTNESS_MODE, // Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); // some ROM may ANF if set brightness to 0 lp.screenBrightness = Math.max(brightness, 0.01f); activity.getWindow().setAttributes(lp); } }