Android implementation shutdown restart method sharing


To achieve the system restart of APK requires the permission of system. Add android:sharedUserId=” android.uid.system “in AndroidManifest.xml, and then modify the signature.

Reference for specific methods:

Click open link

1. Use PowerManager to achieve: Code:

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

2. Send REBOOT broadcast: Code:

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