我想重新启动我的Android设备(做Android的移植)进行测试。Android运行时命令问题
我的代码:
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("reboot");
InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
Log.i("runtime","line : " + line);
}
} catch (Throwable t) {
t.printStackTrace();
}
但设备未重启。
如果我改变命令
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("ls");
它运行良好,显示所有目录。
当我在adb shell中输入“reboot”时,它也起作用。为什么???
重新启动只是工具箱命令之一,我也运行其他命令,可以从shell工作。 但是,除了'ls'之外,它们都不能从rt.exec工作。 有人能告诉我如何使它从android运行时工作? 感谢
壳也许是可行的,因为你有一个root shell。如果您在非root用户的shell中执行此操作: $ reboot reboot:操作不允许 – 2011-06-09 09:12:12