简体   繁体   中英

How to capture unlock screen event in Window phone 7.1?

如何捕获屏幕解锁事件,然后在Window phone 7.1中解锁屏幕时从我的应用程序中触发一些事件?

You can handle the PhoneApplicationFrame.Unobscured event. The only problem is that this event will fire when other types of chrome is removed (such as a MessageBox being closed).

However, you could keep track of a variable that checks if the Activated event has been fired as that event is raised when the phone is unlocked.

So in your Unobscured event, check if the flag in the Activated event is set to true and you can then assume, with relatively high confidence, that the user has unlocked their phone. (This is untested but it seems like it would work).

From MSDN :

In an ordinary app, the following events occur.

  • When the phone is locked, first the Obscured event is raised, and then the Deactivated event is raised. You can check the IsLocked property of the ObscuredEventArgs to determine whether the lock screen caused the deactivation.

  • When the phone is unlocked, the Activated event is raised, and then the Unobscured event is raised.

In an app that use location services and that is specially configured to run continuously in the background, the following events occur.

  • When the phone is locked, the Obscured event is raised. You can check the IsLocked property of the ObscuredEventArgs to determine whether the lock screen obscured the app.

  • When the phone is unlocked, the Unobscured event is raised.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM