软件编程
位置:首页>> 软件编程>> Android编程>> Android实现关机重启的方法分享

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

  发布时间:2022-11-13 21:32:33 

标签: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);
}


0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com