1

I have a receiver which listens for shutdown intent.

The moment it receives that, i want the phone to restart instead of shutting down.

I have a rooted phone. Is it possible to send Linux commands like "su " & "reboot" when shutdown signal is received.

Vinod K
  • 1,637
  • 10
  • 30
  • 44
  • Got the answer here . http://stackoverflow.com/questions/5484535/runtime-exec-reboot-in-android – Vinod K Jul 05 '13 at 08:57

2 Answers2

0

You can try this code:

ProcessBuilder pb = new ProcessBuilder(new String[] { "su", "-c", "/system/bin/reboot" });
Process process = pb.start();
process.waitFor();
Eugene
  • 500
  • 3
  • 8
0

I did this with one of my Android application. However I use Root Tools to issue the command. Here is the snippet:

getShell(true).add(new CommandCapture(1, "reboot"));

I chose to use Root Tools as it will handle all actions related to su. The full class can be found at my github.

Rashidi Zin
  • 254
  • 1
  • 4
  • 18