Runtime.exec() : Reboot in Android?

后端 未结 5 1131
慢半拍i
慢半拍i 2020-11-28 07:41

I\'m looking for a solution which can be used to reboot a rooted device. I jknow that rebooting a device is very poor design for the user, as stated here, and it\'s not real

5条回答
  •  日久生厌
    2020-11-28 08:26

    This code works on Samsung Galaxy S2, S4, Sony Xperia S (LTi 26)

    public static void rebootDevice()
    {
        try 
        {           
            Process process = Runtime.getRuntime().exec("su");
            DataOutputStream os = new DataOutputStream(process.getOutputStream());
            os.writeBytes("reboot \n");
        } 
        catch (Throwable t) {t.printStackTrace;}
    }
    

提交回复
热议问题