0

I want to create an app that can shutdown the phone after a time set by the user , I dont know really how to start .

Any help would be much appreciated .Thanks.

Massadi
  • 21
  • 1
  • 8

2 Answers2

1

For obvious reasons, you cannot power off a device programmatically.

ShadowGod
  • 7,891
  • 3
  • 28
  • 31
0

So far It's only possible with rooted device or app should be signed with the system firmware signing key.

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

refs:

Community
  • 1
  • 1
j2ko
  • 2,479
  • 1
  • 16
  • 29