本文介绍了编程更改自适应亮度水平的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改自适应亮度级别编程,Android上的棒棒糖?

How can I change the adaptive brightness level programmatically, on Android Lollipop?

我知道如何改变手动亮度,并打开或关闭的自适应亮度。它是这样做的:
Settings.System.putInt(CR,Settings.System.SCREEN_BRIGHTNESS,newLevel);

I know how to change the manual brightness level, and to toggle on or off the adaptive brightness. It is done like that:Settings.System.putInt(cr, Settings.System.SCREEN_BRIGHTNESS, newLevel);

然而,自适应亮度已启用,操作系统与另一亮度比不同将其结合起来说明书一本。

However, with adaptive brightness is enabled, the OS combines it with another brightness level which is different than the manual one.

有没有办法做到这一点?

Is there a way to do this?

目标/最小/最大SDK是21。

Target/min/max SDK is 21.

干杯!

推荐答案

不知道为什么,但有一个隐藏的常量 SCREEN_AUTO_BRIGHTNESS_ADJ Android中的API来调整亮度自适应。但是你可以通过screen_auto_brightness_adj字符串值,而不是像我一样。

Don't know why but there is a hidden constant SCREEN_AUTO_BRIGHTNESS_ADJ in Android API to adjust adaptive brightness. But you can pass "screen_auto_brightness_adj" string value instead like I did.

自适应亮度调整存储在范围浮点值[-1; 1]。如果您在使用范围内的亮度值[0; 255],你可以将其转换为正确的值,如下所示

Adaptive brightness adjustment is stored as float value in range [-1;1]. If you use brightness value in range [0;255], you can convert it to proper value as shown below.

float value = (((float)brightness*2)/255) - 1.0f;
Settings.System.putFloat(contentResolver, "screen_auto_brightness_adj", value);

这篇关于编程更改自适应亮度水平的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 17:40