tags:

views:

56

answers:

1

I'm developing an application for Android 1.6 and newer which contains a functionality that switches the phone to sleep.

I tried to find a way of how to do that and I found the goToSleep method in the PowerManager class, but unfortunately the usage of that method requires android.permission.DEVICE_POWER permission which is a system level permission allowed only for system apps only.

Does anybody know an alternative way of forcing the phone to go into sleep mode or how to sign an application to gain the above mentioned permission and to allow the usage of the goToSleep method? Thank you!

+2  A: 

I'm developing an application for Android 1.6 and newer which contains a functionality that switches the phone to sleep.

AFAIK, that is not supported by the Android SDK for ordinary apps.

or how to sign an application to gain the above mentioned permission and to allow the usage of the goToSleep method?

That requires you to compile and install your own firmware.

CommonsWare
Any other way to force the phone to go to sleep or at least to switch the screen off you know of?
crazybyte
@crazybyte: Ask the user politely to stop touching their phone. :-)
CommonsWare
LOL. Thanks, a very good idea, but I'm afraid it won't work. You see they are pretty stubborn and set in their ways :P
crazybyte
@crazybyte: Yeah, well, I don't have any better answers for you, though. Sorry!
CommonsWare
No problem. Thanks anyway.
crazybyte