In your activity's onCreate: getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
No need for a permission, no need to do stuff as the user enters and leaves your activity, no chance of having bugs where you prevent the device from sleeping when the user isn't in your app. I wish more people would use this instead of directly messing with the power manager. On Tue, Aug 25, 2009 at 1:01 PM, Georgy <[email protected]> wrote: > > Hello, > > I read a lot of posts concerning preventing the screen auto lock but > didn't find an efficient way. > > Isn't there any simple line I could put to do such a thing? everything > looked so complicated, or didn't work. > > thanks > > > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

