How to Reboot phone programmatically?

前端 未结 5 1423
情深已故
情深已故 2021-01-17 04:27

I am creating app(only for Android 6) in which I have to give reboot functionality using button click. I am using following code:

PowerManager pm =(PowerMan         


        
5条回答
  •  生来不讨喜
    2021-01-17 05:06

    Process proc = null;
        try {
            proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot" });
            try {
                proc.waitFor();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    

提交回复
热议问题