现在的位置: 首页 > 综合 > 正文

android实现自动关机代码

2013年12月13日 ⁄ 综合 ⁄ 共 269字 ⁄ 字号 评论关闭
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权限!!!

抱歉!评论已关闭.