On Thu, Dec 2, 2010 at 5:44 PM, Peter Eastman <peter.east...@gmail.com> wrote:
> How can I detect when the screen is locked?

Watch for ACTION_SCREEN_OFF broadcasts -- it's the closest thing, AFAIK.

> I'm writing a game, and
> have found that sometimes users will pause the game by just hitting
> the power button to turn off the screen.  onPause() gets called then
> as expected.  But onResume() gets called as soon as they turn the
> screen back on, causing my game to start running again, even though
> it's hidden behind the lock screen.  Calling getVisibility() on the
> View also returns VISIBLE, even though it isn't.  How can I tell when
> my activity is actually visible, not hidden by the lock screen?

To find out when the user gets past the lock screen or keyguard, watch
for ACTION_USER_PRESENT broadcasts.

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

_Android Programming Tutorials_ Version 3.0.1 Available!

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to