Hi all I am just curious to find out some code that can pro-grammatically REBOOT , SHUTDOWN and enter in to DOWNLOAD MODE mobile phones with. I have been exhausted scouring the internet to find something to do with this but have failed. Does any one have any ideas/links/references ?
If your app is signed with the system key, you can use reboot().
On the other hand, if you have root you can still do it (this doesn't work on a few ROMs, mainly a few stock HTC ones.
Shutdown:
try {
Process proc = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "reboot -p" });
proc.waitFor();
} catch (Exception ex) {
ex.printStackTrace();
}
Restart:
Same code, just use reboot
instead of reboot -p
.
AFAIK, it is not possible to boot into "Download Mode" using any API, but on a rooted device you may be able to do it using the adb
binary
来源:https://stackoverflow.com/questions/15930850/code-to-restart-shutdown-and-enter-in-to-download-mode-for-android-phones