Wednesday, June 22, 2011

Re: [android-developers] permission for PowerManager.goToSleep

On Wed, Jun 22, 2011 at 1:19 AM, wasabee18 <wasabee18@gmail.com> wrote:
> 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 ?

Ordinary Android SDK applications cannot hold that permission, AFAIK.

> If it is not possible to lock the screen/ the entire device this way,
> what is the preferred way to do it ?

Let the device lock on its own after user inactivity.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in London: http://bit.ly/smand1, http://bit.ly/smand2

--
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate