android实现自动关机的具体方法
程序员文章站
2023-11-04 14:32:22
[java] 复制代码 代码如下:private void shutdown() { &...
[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权限!!!
下一篇: 怎么做酸萝卜,赶紧学起来