1

我不明白为什么运行以下代码时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?
4

0 回答 0