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

前端 未结 1 1569
心在旅途
心在旅途 2021-01-23 08:42

Hi all I am just curious to find out some code that can pro-grammatically REBOOT , SHUTDOWN and enter in to DOWNL

相关标签:
1条回答
  • 2021-01-23 09:11

    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

    0 讨论(0)
提交回复
热议问题