Java 使用命令重新启动恢复
我不明白为什么Android在运行以下代码时不会自动重启。为了解决这个问题,我添加了System.exit(0);它是有效的,但为什么没有这个呢? 我不认为该系统。退出(0);这是最好的解决方法。 提前谢谢Java 使用命令重新启动恢复,java,android,process,recovery,reboot,Java,Android,Process,Recovery,Reboot,我不明白为什么Android在运行以下代码时不会自动重启。为了解决这个问题,我添加了System.exit(0);它是有效的,但为什么没有这个呢? 我不认为该系统。退出(0);这是最好的解决方法。 提前谢谢 Process p = Runtime.getRuntime().exec("su"); OutputStream os = p.getOutputStream(); os.write("mkdir -p /cache/recovery/\n".getBytes()); os.write("
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?
将“\n”添加到“重新启动恢复”中是否有帮助?是的,现在它可以工作了。。谢谢!