手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >android实现自动关机的具体方法
android实现自动关机的具体方法
摘要:[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权限!!!

【android实现自动关机的具体方法】相关文章:

Android判断包名和类名是否存在的方法

基于Android中的 AutoCompleteTextView实现自动填充

Android 读写文件方法汇总

android 左右滑动+索引图标实现方法与代码

Android 实用工具之emulator介绍

Android 用SQLite实现事务的方法

Android HTTP 实现与服务器通信

Android 完全退出应用程序的解决方法

android帮助文档打开慢的三种解决方法

android layout XML解析错误的解决方法

精品推荐
分类导航