在恢复 Android 中重新启动
我终于成功地让重启代码工作了。我使用了以下代码:
Runtime runtime = Runtime.getRuntime();
Process proc = null;
OutputStreamWriter osw = null;
StringBuilder sbstdOut = new StringBuilder();
StringBuilder sbstdErr = new StringBuilder();
String command="/system/bin/reboot";
try { // Run Script
proc = runtime.exec("su");
osw = new OutputStreamWriter(proc.getOutputStream());
osw.write(command);
osw.flush();
osw.close();
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (osw != null) {
try {
osw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
try {
if (proc != null)
proc.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
sbstdOut.append(ReadBufferedReader(new InputStreamReader(proc
.getInputStream())));
sbstdErr.append(ReadBufferedReader(new InputStreamReader(proc
.getErrorStream())));
if (proc.exitValue() != 0) {
}
现在我想要一个将设备重新启动到恢复模式的代码。该应用程序仅适用于三星 Galaxy S。我没有找到任何用于在恢复中重新启动的代码,是否有任何方法可以通过代码在恢复中重新启动?
I've finally managed to get the Reboot code work. I used following code :
Runtime runtime = Runtime.getRuntime();
Process proc = null;
OutputStreamWriter osw = null;
StringBuilder sbstdOut = new StringBuilder();
StringBuilder sbstdErr = new StringBuilder();
String command="/system/bin/reboot";
try { // Run Script
proc = runtime.exec("su");
osw = new OutputStreamWriter(proc.getOutputStream());
osw.write(command);
osw.flush();
osw.close();
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (osw != null) {
try {
osw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
try {
if (proc != null)
proc.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
sbstdOut.append(ReadBufferedReader(new InputStreamReader(proc
.getInputStream())));
sbstdErr.append(ReadBufferedReader(new InputStreamReader(proc
.getErrorStream())));
if (proc.exitValue() != 0) {
}
Now I want a code that will reboot the device into recovery mode. The application will be only for Samsung Galaxy S. I didn't found any code for reboot in recovery, is there any way to reboot in recovery via code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果reboot命令的版本和它在该设备上调用的后端支持它,这可能会起作用:
当然要意识到,当您使用su程序时,您正在玩不受支持的android修改。
If the version of the reboot command and the backend it calls on that device supports it, this may work:
Realize of course that the minute you use the su program you are playing with unsupported modifications of android.
为什么你不使用:
((PowerManager) getSystemService(Context.POWER_SERVICE)).reboot("recovery");
?
http://developer.android.com /reference/android/os/PowerManager.html#reboot%28java.lang.String%29
Why are you not using:
((PowerManager) getSystemService(Context.POWER_SERVICE)).reboot("recovery");
?
http://developer.android.com/reference/android/os/PowerManager.html#reboot%28java.lang.String%29