Android superuser shutdown/reboot commands not doing anything
I am trying to make an app that can shutdown/reboot your phone at the touch of a button. I found a command online for reboot:
public void rebootPhone() {
try {
Runtime.getRuntime().exec("su");
Runtime.getRuntime().exec(开发者_开发知识库"reboot");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I understand this requires root (for the "su" superuser command); My phone has been rooted so I can gain su access. However when this method is run (after I press 'yes' on the prompt to allow su access) the phone does not reboot, nothing happens! Is there something else i need to include to make the phone reboot?
Also, what is the su command for shutdown (i.e. to just turn your phone off)? I can't find it anywhere on the net.
You can't "su" in one process and "reboot" in another expecting it to have super user status. The command "su -c reboot" might work for you though.
精彩评论