直接上代码
/**
* 当前Activity 改变背光
*/
private void changeLEDLight(){
WindowManager.LayoutParams localLayoutParams = getWindow()
.getAttributes();
localLayoutParams.screenBrightness = 255.0F;
getWindow().setAttributes(localLayoutParams);
}
/**
* 获得当前屏幕亮度值 0--255
*/
private int getScreenBrightness(){
int screenBrightness;
try{
screenBrightness = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
}
catch (Exception localException){
}
return screenBrightness;
}
/**
* 设置当前屏幕亮度值 0--255
*/
private void setScreenBrightness(int screenBrightness){
try{
Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, screenBrightness);
}
catch (Exception localException){
localException.printStackTrace();
}
}