首页 > 系统 > Android > 正文

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

2019-10-24 20:49:01
字体:
来源:转载
供稿:网友
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权限!!!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表