【发布时间】:2015-03-08 01:13:39
【问题描述】:
我正在尝试以编程方式重新启动我的 Galaxy S3。
我尝试过的事情:
try {
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot" });
proc.waitFor();
} catch (Exception ex) {
Log.i("RebootActivity", "Could not reboot", ex);
}
try {
Runtime.getRuntime().exec(new String[]{"su","-c","reboot now"});
} catch (IOException e) {
e.printStackTrace();
}
try
{
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("reboot now\n");
}
catch (Throwable t)
{
t.printStackTrace();
}
你们知道如何做到这一点吗?
谢谢。
【问题讨论】:
-
如果我尝试
/system/bin/su,我会得到这个异常:java.io.IOException: Error running exec(). Command: [/system/bin/su, -c, reboot now] Working Directory: null Environment: null -
每次重启模拟器时都要输入
"adb shell chmod 777 /dev/tty<>"(当然用串口设备替换/dev/tty") -
@SagarPilkhwal,我没有使用模拟器。我使用的是 Galaxy S3 4.4.2