Programming Tips - How can my app reboot the device?

Date: 2012may15 OS: Android Q. How can my app reboot the device? A. At first glance it seems easy. You request this permission the manifest:
<uses-permission android:name="android.permission.REBOOT"/>
And do this:
// Does NOT work must be a system app void reboot(Context context) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); pm.reboot(null); }
But (as the comment indicates) this doesn't work. It seems you need to be a specially signed system app. You get error:
java.lang.SecurityException: Neither user NNNNN nor current process has android.permission.REBOOT. at android.os.Parcel.readException(Parcel.java:1247)
You can exec() the Linux "reboot" command on a rooted box.