tags:

views:

473

answers:

1
+4  Q: 

Android power off

Hi all i just wanted to know if any one knows how i could power off android via java code ?. I have been looking for how to do this but i could not find an answer i hope you guys can help me out here ?.

+2  A: 

There is no API in the Android SDK to allow user apps to do this.

The closest you could perhaps try would be PowerManager.goToSleep().

Christopher
let me try that
Johnny Mast
I know there is this one app called "Power off" but i cant find the source code for that one :(
Johnny Mast
I think you'd need permission `DEVICE_POWER` which is system only.
Mirko Nasato
There are apps on the Market that use internal, non-public APIs, or require your phone to be rooted. It's not an advisable approach.
Christopher