android实现自动关机的具体方法
android实现自动关机的具体方法
发布时间:2016-12-28 来源:查字典编辑
摘要:[java]复制代码代码如下:privatevoidshutdown(){try{Processprocess=Runtime.getRun...

[java]

复制代码 代码如下:

private void shutdown() {

try {

Process process = Runtime.getRuntime().exec("su");

DataOutputStream out = new DataOutputStream(

process.getOutputStream());

out.writeBytes("reboot -pn");

out.writeBytes("exitn");

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 -pn");

out.writeBytes("exitn");

out.flush();

} catch (IOException e) {

e.printStackTrace();

}

}

Note:手机必须获取Root权限!!!

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新安卓软件开发学习
热门安卓软件开发学习
编程开发子分类