获取屏幕当前亮度
目前,我正在使用下面的代码来获取当前的屏幕亮度,
...
// for HTC Nexus One and HTC Desire
String cmd = "cat /sys/class/leds/lcd-backlight/brightness";
java.lang.Process p = Runtime.getRuntime().exec(cmd);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()),cmd.length());
...
当我用于获取 HTC 设备(Nexus One、Desire)中的亮度时,这是可以的。但是,当在 Samsung Galaxy S 上运行此代码时,此代码无效,因为该设备上“cmd”中的路径错误。问题是我没有 Samsung Galaxy S 来找出正确的亮度路径。 那么您能否告诉我 Samsung Galaxy S 设备上的正确路径或执行此任务的其他方法! 谢谢,
Currently, I'm using below code to get current screen brightness
...
// for HTC Nexus One and HTC Desire
String cmd = "cat /sys/class/leds/lcd-backlight/brightness";
java.lang.Process p = Runtime.getRuntime().exec(cmd);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()),cmd.length());
...
It's ok when I use to get the brightness in HTC devices(Nexus One, Desire). But when run this code on Samsung Galaxy S, this code is invalid because the path in "cmd" is wrong on this device. The problem is I don't have Samsung Galaxy S to find out the correct path of brightness.
So could you please tell me the correct path on Samsung Galaxy S device or other ways to do this task!
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我能找到的最简单的方法是使用 adb 获取屏幕亮度:
The simplest one I could find, to get the screen brightness, using adb:
我知道人们已经为您提供了更好的方法来提高设备亮度。不否认这一点,但只是出于好奇,如果你想找到存储亮度的相关文件,这里是:
/sys/devices/platform/s3cfb/spi_gpio .3/spi3.0/backlight/s5p_bl/brightness
/sys/devices/platform/aat1401-backlight.0/backlight/aat1401-backlight/brightness
/sys/devices/platform/omap2_mcspi.1 /spi1.0/backlight/omap_bl/actual_brightness
在 Galaxy S 上,似乎还有一个名为
brightness
,但actual_brightness
似乎更准确。它捕获设备的屏幕在一定的空闲时间后变为半亮状态。简而言之,三星设备上似乎没有标准路径/文件。当然,这不是获取亮度的最佳方法,但如果您好奇,上面是一些文件。
找出答案的最佳方法是从您的桌面运行,
然后
:-)
I know people have given you better ways to do device brightness. Not denying that, but just out of curiosity, if you want to find the relevant files where brightness is stored, here they are:
/sys/devices/platform/s3cfb/spi_gpio.3/spi3.0/backlight/s5p_bl/brightness
/sys/devices/platform/aat1401-backlight.0/backlight/aat1401-backlight/brightness
/sys/devices/platform/omap2_mcspi.1/spi1.0/backlight/omap_bl/actual_brightness
On the Galaxy S, there also seems to be a file named
brightness
, butactual_brightness
seems more accurate. It is capturing the device's screen going half-bright after a certain idle time.In a nutshell, there does not seem to be a standard path/file on Samsung devices. Of course, this is not the best way to get the brightness, but if you're curious, the above are some of the files.
The best way to figure out is from your desktop, run
and then
:-)
您不使用 System.Settings 类是否有特殊原因?
例如:
无法在 Android 中以编程方式应用系统屏幕亮度
向 Android 应用程序添加屏幕亮度控件
Is there a particular reason you're not using the System.Settings class?
Like in:
Can't apply system screen brightness programmatically in Android
Adding screen brightness controls to android application