html5中文学习网

您的位置: 首页 > android » 正文

android实现自动关机的具体方法_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权限!!!
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助