手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >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 实用工具之emulator介绍

android Watchdog 实现剖析

Android中实现动态切换组件背景的操作

Android开发实现HttpClient工具类

Android开发之SQLite的使用方法

Android中隐藏标题栏和状态栏的方法

基于Android中实现定时器的3种解决方法

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

android滑动解锁震动效果的开启和取消

Android 文件操作方法

精品推荐
分类导航