Search code examples
androidshutdownroot-access

How to shutdown the android device programatically?


My device is a rooted one.

I know that for rebooting device we use shell command "su -c reboot". In some other posts I see people posting shutdown command as "su -c shutdown", but this does not work and also there is a permission called ACTION_SHUTDOWN but those permissions are used for system applications.

Is there any command which shut downs the device?


Solution

  • /**
     * Low-level function turn the device off immediately, without trying
     * to be clean.  Most people should use
     * {@link android.internal.app.ShutdownThread} for a clean shutdown.
     *
     * @deprecated
     * @hide
     */
    @Deprecated
    public static native void shutdown();
    

    try using:

    su reboot -p.
    

    This works on some devices however it does not shutdown cleanly.