,

Running Under the Lock Screen

Users expect some kinds of apps to run under a locked screen. These apps include music players, mapping apps, stop watches, and so on.

In the first release of the Windows Phone OS, running under the lock screen was favorable to apps that wanted to avoid being tombstoned. These were apps that were slow to load or relied on complex state models. This was alleviated, however, with the introduction of fast application switching in Windows Phone 7.5. Now apps are placed in a dormant state and remain in memory.


Note

Running under the lock screen is not an alternative to implementing efficient transient state persistency. Recall that an app may still be tombstoned if the phone runs low on memory.


The following steps outline how to enable your app to run under the locked screen:

1. Set PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled.

2. Detect when the lock screen is engaged, or disengaged, by handling the PhoneApplicationFrame.Obscured and Unobscured events, respectively.

3. When the lock screen is engaged your app should reduce its processing to a bare minimum to minimize CPU usage and thus battery consumption.

4. When the lock screen is disengaged your app should resume from where it left off.

5. Optionally, you should prompt the user to allow him or her to opt-in to running under the lock screen, and/or provide an options setting for enabling or disabling running under the lock screen.


Tip

To engage the lock screen within the Windows Phone emulator, press F12 on the computer keyboard twice. F12 emulates the power button on the phone. Pressing it once locks the phone and turns off the display; twice turns the display on again with the lock screen engaged. The mouse can be used to disengage the lock screen by sliding the lock screen up.

To engage the lock screen when debugging on an actual device (or on the emulator), use the Simulation Dashboard, which can be opened by selecting Simulation Dashboard from the Tools menu in Visual Studio.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.242.118