Search code examples
androidshutdown

Android: shutting down the phone programmatically


Is it possible to shut down the whole phone by an app? How? Do I need to root the phone?


Solution

  • You need the DEVICE_POWER permission in order to shut the phone completely off which requires the device being rooted.

    You can use the PowerManager to get it to sleep or reboot.

    http://developer.android.com/reference/android/os/PowerManager.html#reboot(java.lang.String)

    Reboot also requires a permission:

    http://developer.android.com/reference/android/Manifest.permission.html#REBOOT