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.
Asked
Active
Viewed 1,726 times
1 Answers
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.
-
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