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

旧时模样 提交于 2019-12-02 10:28:26

问题


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 ?


回答1:


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

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