我正在寻找一种可用于重新启动已root 设备的解决方案。我知道重启设备对用户来说是非常糟糕的设计,as stated here ,它并不是真正的应用程序。主要目的是在我的测试期间重启手机(我在一个视频聊天应用程序上工作,有时我需要在一切都向南时重启)
我观察到,在终端(例如 adb shell
或 ConnectBot)中使用 reboot 重启手机比使用 ACTION_REBOOT 重启手机要快得多。 ,反正我用不了。
目前,我可以通过
获得 super 用户权限Process root = Runtime.getRuntime().exec("su");
但我无法进行实际的重启。我尝试了 G1 (HTC) 和 Galaxy S (Samsung),但没有成功。我在 /system/bin/reboot
这是我的一些尝试:
Process reboot = Runtime.getRuntime().exec("/system/bin/reboot");
Process reboot = Runtime.getRuntime().exec("reboot");
Process reboot = Runtime.getRuntime().exec("su reboot");
我读过 this article关于 Runtime.exec() 的陷阱,但我想我不是这种情况。
由于使用 ConnectBot 使我能够执行这样的操作,我很确定这是可能的。请不要告诉我去看看ConnectBot code ,这是一个大而复杂的项目:)
你能帮我解决这个问题吗?
谢谢。
最佳答案
经过数周的搜索终于:
Runtime.getRuntime().exec(new String[]{"/system/bin/su","-c","reboot now"});
关于java - 运行时.exec() : Reboot in Android?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5484535/