Android实现关机重启 Android实现关机重启的方法分享

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Android实现关机重启 Android实现关机重启的方法分享

  2021-03-19 我要评论
想了解Android实现关机重启的方法讲解的相关内容吗,在本文为您仔细讲解Android实现关机重启的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Android,关机,重启,下面大家一起来学习吧。

实现系统重启的APK需要system的权限,在AndroidManifest.xml中增加android:sharedUserId="android.uid.system",再修改签名即可;

具体方法参考:

点击打开链接

1、使用PowerManager来实现:
代码:

复制代码 代码如下:

private void rebootSystem(){ 
    PowerManager pManager=(PowerManager) getSystemService(Context.POWER_SERVICE); 
    pManager.reboot(""); 

2、发送REBOOT广播:
代码:

复制代码 代码如下:

private void rebootSystem(){
 Intent reboot = new Intent(Intent.ACTION_REBOOT);
 reboot.putExtra("nowait", 1);
 reboot.putExtra("interval", 1);
 reboot.putExtra("window", 0);
 sendBroadcast(reboot);
}

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们