1

An earlier question on the subject explains that you can request a reboot with proper permissions, but that the OS may cancel it. I would like a Device Administration application on a rooted phone to perform a shutdown on e.g. maximum failed password attempts, rather than data wipe. Because this is a security issue, stronger guarantees about the shutdown/reboot than those provided by PowerManager would be nice.

Community
  • 1
  • 1
Jacob
  • 327
  • 3
  • 13

1 Answers1

5

I answered it before here: Android 2.2: Reboot device programmatically

In short,

try {
    Runtime.getRuntime().exec("su");
    Runtime.getRuntime().exec("reboot");
} catch (IOException e) {
}      

It is equivalent to do adb reboot. Its effect is immediate.

Community
  • 1
  • 1
Aleadam
  • 40,203
  • 9
  • 86
  • 108
  • This looks good. Not sure how I missed the earlier question, I think I may have searched for shutdown instead of reboot. – Jacob Apr 21 '11 at 00:43