Code to Restart , Shutdown and enter in to Download Mode for Android Phones?

梦想与她 提交于 2019-12-02 07:18:55

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!