Search code examples
startupshutdown

Schedule Turn on/off android device programmatically on specific times


Hell all, I am developing an android app on rooted device, and I need the power off this device on specific time say on 12:00 AM, and power on again after 8 hours, say on 8:00 AM.

I did a search on the internet, and I found some lines of code that do the shutdown process, the code is:

  try {
        Process proc = Runtime.getRuntime()
                      .exec(new String[]{ "su", "-c", "reboot -p" });
        proc.waitFor();

      } catch (Exception ex) {
           ex.printStackTrace();
      }

The above code will shutdown the device only on rooted ones, what I need now is to create some timer or some line of code which will turn the device on on the desired time. any ideas?

Thanks


Solution

  • this is simply not possible, once you turn it off you lose control over the device.