reboot from Shell - Android Android OS

Android examples for Android OS:Shell

Description

reboot from Shell

Demo Code


//package com.java2s;

import java.io.DataOutputStream;

import java.io.IOException;

public class Main {
    public static void reboot() {

        Process p;// w w w.j ava 2 s .  com
        try {
            p = Runtime.getRuntime().exec("su");
            DataOutputStream os = new DataOutputStream(p.getOutputStream());

            os.writeBytes("reboot\n");
            os.writeBytes("exit\n");
            os.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related Tutorials