有没有办法获得最低显示亮度值。假设从设置我将displaybrightnessseckbar设置为0.但是android系统不会将系统亮度值设为0,而是将其设置为最小显示亮度值。此最小显示亮度值因设备而异。我怎样才能得到这个值
答案 0 :(得分:1)
您可以使用 BRIGHTNESS_OVERRIDE_OFF (来自文档:表示当此窗口位于此窗口时,屏幕或按钮背光亮度应设置为最低值。)
Window win = getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
winParams.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
win.setAttributes(winParams);
现在您可以调用getAtributes并查看Device设置的值。
答案 1 :(得分:1)
public static int getMinimumScreenBrightnessSetting (Context context) {
final Resources res = Resources.getSystem();
int id = res.getIdentifier("config_screenBrightnessSettingMinimum", "integer", "android"); // API17+
if (id == 0)
id = res.getIdentifier("config_screenBrightnessDim", "integer", "android"); // lower API levels
if (id != 0) {
try {
return res.getInteger(id);
}
catch (Resources.NotFoundException e) {
// ignore
}
}
return 0;
}
public static int getMaximumScreenBrightnessSetting (Context context) {
final Resources res = Resources.getSystem();
final int id = res.getIdentifier("config_screenBrightnessSettingMaximum", "integer", "android"); // API17+
if (id != 0) {
try {
return res.getInteger(id);
}
catch (Resources.NotFoundException e) {
// ignore
}
}
return 255;
}