Thanks to @Fabin Paul:
The only way to do this without root and without tasker is via adb by executing these commands:
adb reboot
-- no root required; for reboot, or
adb shell reboot -p
-- no root required.
adb shell shutdown
-- needs root.
adb shell su
must be run before it, preferably like this: adb shell
→ su
→ shutdown
-- for shutdown / power off -- on a computer while the tablet is connected to the computer with USB debugging enabled.
These commands work via adb as adb is more privileged than a normal user, although not as much as root on-device.
The reason why you simply can't run the commands reboot
or shutdown
through a terminal emulator on-device or through an app without root is because of the following reasons in order:
Android apps use Java as their programming language.
Java has a function System.exec(String)
which allows the program to execute a shell command (specified by the String
argument to the function).
If an app did not need root to run the reboot
or shutdown
commands, it could easily perpetrate Denial Of Service (DoS) attacks on a device (basically like a Trojan (in computer parlance)).
As you can understand, the reboot/shutdown functionality needs to be protected from userspace software, hence, for your other question, we will help you to try to root your device so that you can get this functionality. Otherwise, there is no other way I can help you.