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.
For obvious reasons, you cannot power off a device programmatically.
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: