public void reboot(){
String cmd = "su -c reboot";
try {
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
new AlertDialog.Builder(MainActivity.this).setTitle("Error").setMessage(
e.getMessage()).setPositiveButton("OK", null).show();
}
}
public void shutdown(){
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream out = new DataOutputStream(
process.getOutputStream());
out.writeBytes("reboot -p\n");
out.writeBytes("exit\n");
out.flush();
} catch (IOException e) {
e.printStackTrace();
new AlertDialog.Builder(MainActivity.this).setTitle("Error").setMessage(
e.getMessage()).setPositiveButton("OK", null).show();
}
}
String cmd = "su -c reboot";
try {
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
new AlertDialog.Builder(MainActivity.this).setTitle("Error").setMessage(
e.getMessage()).setPositiveButton("OK", null).show();
}
}
public void shutdown(){
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream out = new DataOutputStream(
process.getOutputStream());
out.writeBytes("reboot -p\n");
out.writeBytes("exit\n");
out.flush();
} catch (IOException e) {
e.printStackTrace();
new AlertDialog.Builder(MainActivity.this).setTitle("Error").setMessage(
e.getMessage()).setPositiveButton("OK", null).show();
}
}