简体   繁体   English

如何在Window Phone 7.1中捕获解锁屏幕事件?

[英]How to capture unlock screen event in Window phone 7.1?

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

You can handle the PhoneApplicationFrame.Unobscured event. 您可以处理PhoneApplicationFrame.Unobscured事件。 The only problem is that this event will fire when other types of chrome is removed (such as a MessageBox being closed). 唯一的问题是,当删除其他类型的chrome(例如MessageBox被关闭)时,此事件将触发。

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. 但是,您可以跟踪一个变量,该变量检查Activated事件是否已被触发,因为当手机解锁时该事件被引发。

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. 因此,在您的Unobscured事件中,检查Activated事件中的标志是否设置为true ,然后您可以相对较高的信心假设用户已解锁其电话。 (This is untested but it seems like it would work). (这是未经测试但看起来它会起作用)。

From MSDN : 来自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. 手机锁定后,首先会引发Obscured事件,然后引发Deactivated事件。 You can check the IsLocked property of the ObscuredEventArgs to determine whether the lock screen caused the deactivation. 您可以检查ObscuredEventArgs的IsLocked属性,以确定锁定屏幕是否导致停用。

  • When the phone is unlocked, the Activated event is raised, and then the Unobscured event is raised. 手机解锁后,会激活Activated事件,然后引发Unobscured事件。

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. 您可以检查ObscuredEventArgs的IsLocked属性,以确定锁定屏幕是否遮盖了应用程序。

  • When the phone is unlocked, the Unobscured event is raised. 当手机解锁时,会出现Unobscured事件。

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

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