0

at present the following code is setting the screen brightness level to 0 but it is not dimming the screen.can somebody help me out.the android version is 4.0. thanks in advance.

android.provider.Settings.System.putInt(
 context.getContentResolver(),android.provider.Settings.System.SCREEN_BRIGHTNESS, 0);
Abhishek Patel
  • 4,280
  • 1
  • 24
  • 38
akshaya
  • 1
  • 1

2 Answers2

0
Settings.System.putInt(this.getContentResolver(),
        Settings.System.SCREEN_BRIGHTNESS, 20);

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 0.2f; // 100 / 100.0f;
getWindow().setAttributes(lp);

startActivity(new Intent(this,RefreshScreen.class));
OShiffer
  • 1,366
  • 12
  • 27
0

Try this:

public static void wakeDevice(Context context) {
    PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = powerManager.newWakeLock(
            (PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK
                    | PowerManager.ACQUIRE_CAUSES_WAKEUP), "");

    //calling this will Dim the screen
    wakeLock.acquire();

    //if  you want to release the dim state
    //wakeLock.release();
}
Mohammad Arman
  • 7,020
  • 2
  • 36
  • 50