Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/211.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用命令重新启动恢复_Java_Android_Process_Recovery_Reboot - Fatal编程技术网

Java 使用命令重新启动恢复

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("

我不明白为什么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("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”添加到“重新启动恢复”中是否有帮助?是的,现在它可以工作了。。谢谢!