Windows Phone 8 detect screen unlock

谁说胖子不能爱 提交于 2019-12-24 03:44:18

问题


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?

What methods, if any, are called when the phone is unlocked?


回答1:


The frame's Unobscured event will fire when the user unlocks (it will also fire Obscured when the phone is being locked).

However these events will also fire for a MessageBox, a Reminder and the like so you will get other false positive. However it should be possible to detect the scenario you are after pretty easily.

See this MSDN link for more details.




回答2:


There are two proper events on PhoneApplicationFrame class for lock/unlock:

PhoneApplicationFrame.Unobscured Event

PhoneApplicationFrame.Obscured Event

There is a bit more description about that on MSDN: How to simulate the lock screen for Windows Phone



来源:https://stackoverflow.com/questions/15123785/windows-phone-8-detect-screen-unlock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!