2

I am trying to switch off android device through my program. It actually gets switched off but it restarts itself. I want the phone not to restart again by itself. How can I do that?

Kate Gregory
  • 18,808
  • 8
  • 56
  • 85
sanjeev
  • 1,343
  • 3
  • 16
  • 28
  • 1
    Second result while using the search terms "[android] turn off phone" http://stackoverflow.com/questions/7591993/how-to-turn-off-android-phone-programmatically – Jwc24678 Mar 25 '12 at 13:22
  • You will need the device to have root access first. http://stackoverflow.com/questions/6305491/power-off-or-restart-an-android-device-via-code-program – Alexandre Hitchcox Mar 25 '12 at 13:23
  • i have checked all those links but they all are for rebooting the device. i want to shut down the device – sanjeev Mar 25 '12 at 13:58
  • possible duplicate of [How to shutdown an android mobile programatically?](http://stackoverflow.com/questions/10411650/how-to-shutdown-an-android-mobile-programatically) – Flow Apr 15 '14 at 12:18

2 Answers2

2

This has been asked on StackOverflow in the past. The effective answer is that you would require the DEVICE_POWER permission in order to shut the phone completely off, but the user would need a rooted phone to give your app permission to that control anyway.

Best you could hope for is PowerManager.goToSleep()

iandouglas
  • 4,146
  • 2
  • 33
  • 33
0

I suppose you have found the answer,but this might help other users.

It's not possible to turn off your device. Here is an easy way to lock it :

You won't need any permissions, because some are only granted for system apps(like DEVICE_POWER and REBOOT). You also won't need to root your device.

Community
  • 1
  • 1
The.Blue.Shrimp
  • 193
  • 2
  • 18