当前位置: 移动技术网 > IT编程>移动开发>Android > android实现自动关机的具体方法

android实现自动关机的具体方法

2019年07月24日  | 移动技术网IT编程  | 我要评论

老师好 阴三儿,奇热网电视剧,锵锵三人行20120926

[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权限!!!

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网