Dave's Brain

Browse - Programming Tips - How can my app reboot the device?

Date: 2012may15
Platform: 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.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.