关机:
In frameworks/base/services/java/com/android/server/BatteryService.java

Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);

intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

mContext.startActivity(intent);

重启:
Intent i = new Intent(Intent.ACTION_REBOOT);
i.putExtra("nowait", 1);
i.putExtra("interval", 1);
i.putExtra("window", 0);
sendBroadcast(i);

注意添加权限。

来自: http://topic.csdn.net/u/20100423 ... 2-55f6c4c5e412.html

更多相关文章

  1. Android存储权限
  2. Android常用代码之普通及系统权限静默安装APK
  3. 常用的android权限配置和常用工具代码
  4. Android 编写使用root权限的android应用程序
  5. Android SdCard写入权限
  6. Android 允许权限
  7. android访问SD卡的权限
  8. android权限机制,你真的了解么

随机推荐

  1. android java 文件的读写
  2. android表格效果--ListView隔行变色
  3. android studio 获取android app sha1
  4. Android EditText失去焦点可以干的事情
  5. android onTouch
  6. android自由改变Dialog窗口位置的方法
  7. Android动态加载框架DL的架构与基本原理
  8. android 开发第三库
  9. android svg
  10. Android(安卓)studio:报错String index o