Android 应用中的亮度
我通过此方法在我的应用程序中选择亮度Android 应用中的亮度,android,screen-brightness,Android,Screen Brightness,我通过此方法在我的应用程序中选择亮度 public void setBrightness(Context context, int progress) { float BackLightValue = (float) progress/100; WindowManager.LayoutParams layoutParams = ((Activity) context).getWindow().getAttributes(); if (BackLi
public void setBrightness(Context context, int progress) {
float BackLightValue = (float) progress/100;
WindowManager.LayoutParams layoutParams = ((Activity) context).getWindow().getAttributes();
if (BackLightValue == 0.0) {
BackLightValue = 0.01f;
}
layoutParams.screenBrightness = BackLightValue;
// layoutParams.screenBrightness = progress;
((Activity) context).getWindow().setAttributes(layoutParams);
}
此代码可以工作,但如果我转到其他活动,亮度设置将返回到上一个
如何更改所有应用程序中的亮度?或者我必须在所有活动的oncreate方法上恢复它