当前位置:操作系统 > 安卓/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权限!!! 
 
补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,