开发者

Reboot in Recovery Android

I've finally managed to get the Reboot code work. I used following code :

        Runtime runtime = Runtime.getRuntime();
        Process proc = null;
        OutputStreamWriter osw = null;
        StringBuilder sbstdOut = new StringBuilder();
        StringBuilder sbstdErr = new StringBuilder();

        String command="/system/bin/reboot";

        try { // Run Script

            proc = runtime.exec("su");
            osw = new OutputStreamWriter(proc.getOutputStream());
                                osw.write(command);
                    osw.flush();
            osw.close();

        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            if (osw != null) {
                try {
                    osw.close();
                } catch (IOException e) {
                    e.printStackTrace();                    
      开发者_运维知识库          }
            }
        }
        try {
            if (proc != null)
                proc.waitFor();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        sbstdOut.append(ReadBufferedReader(new InputStreamReader(proc
                .getInputStream())));
        sbstdErr.append(ReadBufferedReader(new InputStreamReader(proc
                .getErrorStream())));
        if (proc.exitValue() != 0) {
                    }

Now I want a code that will reboot the device into recovery mode. The application will be only for Samsung Galaxy S. I didn't found any code for reboot in recovery, is there any way to reboot in recovery via code?


If the version of the reboot command and the backend it calls on that device supports it, this may work:

String command="/system/bin/reboot recovery";

Realize of course that the minute you use the su program you are playing with unsupported modifications of android.


Why are you not using:

((PowerManager) getSystemService(Context.POWER_SERVICE)).reboot("recovery");

? http://developer.android.com/reference/android/os/PowerManager.html#reboot%28java.lang.String%29

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜