android实现自动关机的具体方法
时间:2022-09-02 08:41:00|栏目:Android代码|点击: 次
[java]
private 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();
}
}
private 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();
}
}
Note:手机必须获取Root权限!!!
复制代码 代码如下:
private 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();
}
}
private 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();
}
}
Note:手机必须获取Root权限!!!
上一篇:Android Flutter基于WebSocket实现即时通讯功能
栏 目:Android代码
本文标题:android实现自动关机的具体方法
本文地址:http://www.codeinn.net/misctech/212535.html