简体   繁体   English

Windows Phone 8检测到屏幕解锁

[英]Windows Phone 8 detect screen unlock

My WP8 app is set to run underneath the lock screen because it needs to continue to run even while the screen is locked, but I want to be able to detect when the user unlocks their screen, how do I do this? 我的WP8应用程序设置为在锁定屏幕下方运行,因为即使在锁定屏幕的情况下也需要继续运行,但是我希望能够检测到用户何时解锁屏幕,我该怎么做?

What methods, if any, are called when the phone is unlocked? 手机解锁时会调用哪些方法(如果有)?

The frame's Unobscured event will fire when the user unlocks (it will also fire Obscured when the phone is being locked). 该框架的Unobscured事件将触发当用户解锁(它也将火Obscured时,手机被锁定)。

However these events will also fire for a MessageBox, a Reminder and the like so you will get other false positive. 但是,这些事件也会为MessageBox,Reminder等触发,因此您将获得其他误报。 However it should be possible to detect the scenario you are after pretty easily. 但是,应该可以很容易地检测出您的情景。

See this MSDN link for more details . 有关更多详细信息,请参见此MSDN链接

There are two proper events on PhoneApplicationFrame class for lock/unlock: PhoneApplicationFrame类上有两个适当的事件用于锁定/解锁:

PhoneApplicationFrame.Unobscured Event PhoneApplicationFrame.Unobscured事件

PhoneApplicationFrame.Obscured Event PhoneApplicationFrame.Obscured事件

There is a bit more description about that on MSDN: How to simulate the lock screen for Windows Phone 在MSDN上有更多关于它的描述: 如何模拟Windows Phone的锁定屏幕

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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