Tuesday, June 21, 2011

[android-developers] permission for PowerManager.goToSleep

Hi all,

I am trying to lock the screen with the following code:

PowerManager pm = (PowerManager)
getSystemService(Context.POWER_SERVICE);
pm.goToSleep(10);

Even though I added the android.permission.DEVICE_POWER permission in
the manifest file, I get error:

java.lang.SecurityException: Neither user 10024 nor current process
has android.permission.DEVICE_POWER.
I have tested only in emulator.

This issue has been discussed already here (http://comments.gmane.org/
gmane.comp.handhelds.android.devel/100254) but no probing answer has
been given.

Can anyone help now ?
If it is not possible to lock the screen/ the entire device this way,
what is the preferred way to do it ?

Cheers.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment