使用命令重新启动恢复

时间:2013-09-19 23:21:21

标签: java android process recovery reboot

我不明白为什么Android在以下代码运行时不会自动重启。为了解决这个问题,我添加了System.exit(0);它有效,但为什么不呢? 我不认为System.exit(0);是修复它的最佳方法。 提前谢谢!

Process p = Runtime.getRuntime().exec("su");
OutputStream os = p.getOutputStream();
os.write("mkdir -p /cache/recovery/\n".getBytes());
os.write("echo 'boot-recovery' >/cache/recovery/command\n".getBytes());

os.write("echo '--wipe_cache' >> /cache/recovery/command\n".getBytes());

// Trigger the reboot
os.write("echo 'reboot' >> /cache/recovery/command\n".getBytes());
os.write("reboot recovery".getBytes());
os.flush();

// If I add System.exit(0); it works, but why not without this?

0 个答案:

没有答案