android : how to run a shell command from within code
Posted
by ee3509
on Stack Overflow
See other posts from Stack Overflow
or by ee3509
Published on 2010-06-16T15:54:00Z
Indexed on
2010/06/16
17:42 UTC
Read the original article
Hit count: 403
I am trying to execute a command from within my code, the command is "echo 125 > /sys/devices/platform/flashlight.0/leds/flashlight/brightness" and I can run it without problems from adb shell
I am using Runtime class to execute it :
Runtime.getRuntime().exec("echo 125 > /sys/devices/platform/flashlight.0/leds/flashlight/brightness");
However I get a permissions error since I am not supposed to access the sys directory. I have also tried to place the command in a String[] just in case spaces caused a problem but it didn't make much differense.
Does anyone know any workaround for this ?
© Stack Overflow or respective owner