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

I added this code to button onClick and it worked ! But is there a higher value since the screen didn't light MAX ??

A.J
  • 726
  • 1
  • 7
  • 19

5 Answers5

9

As stated in the documentation, no. Setting screenBrightness to 1 should adjust the brightness to full light.

Dalmas
  • 26,409
  • 9
  • 67
  • 80
  • 2
    A nice way to use this is by using the constant `BRIGHTNESS_OVERRIDE_FULL`. Its value is 1.0f – Cristan Nov 28 '17 at 14:56
1

You should be able to set the value as 1L and it should go to max brightness as this is the max brightness

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

Will set it to max brightness..

FabianCook
  • 20,269
  • 16
  • 67
  • 115
0

You should disable screen dimming first before you set the brightness, or you may get a less than MAX brightness ! Try something like this before you set the brightness:

// disable screen dimming (note - this also requires setting in manifest file)
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");
0

You Use this code

float SysBackLightValue = 255f;


android.provider.Settings.System.putInt(BatteryBoosterActivity.this.getContentResolver(),   android.provider.Settings.System.SCREEN_BRIGHTNESS,(int) SysBackLightValue);                                    
Window myWindow =BatteryBoosterActivity.this. getWindow();
WindowManager.LayoutParams winParams = myWindow.getAttributes();                                    winParams.screenBrightness = 255f;
myWindow.setAttributes(winParams);
Wajid
  • 2,235
  • 1
  • 19
  • 29
Uma Shankar
  • 231
  • 4
  • 11
0

A full example shows how to change brightness by coding, foreground, background. brightnessdemo

TeeTracker
  • 7,064
  • 8
  • 40
  • 46