Share via


How to simulate the lock screen for Windows Phone 8

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

This topic contains the following sections.

Events that occur when the phone is locked or unlocked

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.

Lock screen options

The following illustration shows the options that are available in the Simulation Dashboard in Visual Studio for locking or unlocking the screen.

Simulating the lock screen

The Lock Screen option buttons in the Simulation Dashboard are not synchronized with the actual screen state of the target device. For example, if you’re testing your app on a phone and you manually engage or disengage the lock screen on the phone itself, the state of the Lock Screen option buttons on the Simulation Dashboard is not updated.

To simulate locking or unlocking the phone

  1. Run your app on the emulator or a connected device, with or without debugging.

    Or, run your app with app monitoring and profiling to measure its quality and performance. For more information about app monitoring and profiling, see Windows Phone Application Analysis for Windows Phone 8.

  2. In Visual Studio, on the Tools menu, open Simulation Dashboard. Find the Lock Screen section of the dashboard.

  3. To engage the lock screen and lock the phone, select Locked.

  4. Test how your app handles deactivation.

  5. To disengage the lock screen and unlock the phone, select Unlocked.

  6. Test how your app handles activation.