How to capture Screen unlock event and then fire some event from my app when screen is unlocked in Window phone 7.1?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
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 theActivated
event is set totrue
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.