문제

    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 ??

도움이 되었습니까?

해결책

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

다른 팁

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..

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");

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

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top