Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current brightness of the screen

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,

like image 892
Pham Le Sum Avatar asked Nov 29 '22 18:11

Pham Le Sum


1 Answers

The simplest one I could find, to get the screen brightness, using adb:

adb shell settings get system screen_brightness
like image 60
iamtester Avatar answered Dec 05 '22 03:12

iamtester