首先新建一个app然后添加

android:sharedUserId="android.uid.system"

再添加重启的权限

     

然后代码:

public void reboot(Context context){LogsUtil.i(TAG, " reboot");Intent i = new Intent(Intent.ACTION_REBOOT); i.putExtra("nowait", 1);     i.putExtra("interval", 1);  i.putExtra("window", 0);   context.sendBroadcast(i);LogsUtil.i(TAG, " reboot over");}

详细代码和使用步骤详见地址  http://git.oschina.net/cuiran/Counter

更多相关文章

  1. android 发布正式版时用Gradle移除日志打印代码(添加混淆配置)
  2. [置顶] android studio 如何进行格式化代码 快捷键必备
  3. Android源码可行的下载步骤
  4. android纯Java代码写的addView弹窗(亲测可用,欢迎留言)
  5. 整理的Android多种控件步骤
  6. android 代码设置apn

随机推荐

  1. 用 Golang 开发 Android 应用(六)—— Came
  2. 【10.0.1】ArcGIS Runtime for Android之
  3. android用户界面之Widget教程实例汇总
  4. android 局域网聊天工具(可发送文字/语音
  5. Android 内核简单分析
  6. 在mac 上配置AndroidStudio碰到的坑
  7. android HAL介绍
  8. Android(安卓)创建与解析XML(二)—— Dom方
  9. Android:Android学习路线图
  10. Android 各种实现Tab效果的实现方式