1.方法一:
public static void exe_cmd(String cmd){
Process process2 = null;
DataOutputStream dos = null;
try{
process2 = Runtime.getRuntime().exec("su");
dos = new DataOutputStream(process2.getOutputStream());
dos.writeBytes(cmd);//"input keyevent 26");
dos.flush();
dos.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
实现开关以太网 / 背光设置
if(eth_mode){
exe_cmd("ifconfig eth0 up");
}
else {
exe_cmd("ifconfig eth0 down");
}
public void bl_onoff(Boolean mode){
if(mode)exe_cmd("echo 1 > /sys/class/backlight/backlight/bl_power");
else exe_cmd("echo 0 > /sys/class/backlight/backlight/bl_power");
}
2.方法二:
private static void exe_normal_cmd(String cmd){
try {
Run