In previous post I described how to enrich user experience by customizing application tiles. In this post I will show how to enable your application to present some information on phone’s lock screen.
In Windows Phone 8 applications could provide 3 pieces of info on lock screen: application’s icon, count and text. On screenshot below my sample application provides icon, count and some text:
If application selected by user, the lock screen could show app icon defined in app manifest, count and text pulled directly from the application’s primary tile. The secondary tiles does not have an impact on lock screen.
Let’s see how to achieve it. First of all – icon presented on lock screen must be 24×24 transparent PNG image with white pixels (plus transparent pixels obviously). Once such image created, add it to the application and then open application manifest using XML editor as follows (right click on manifest file and select “Open With…”:
Then select XML (Text) Editor:
Locate “DeviceLockImageURI” element (within PrimaryToken/Template definition) and specify path to the image:
To enable application icon and count add new Extensions element and new Extension as follows:
Note:Extension element must be next to Tokens element.
If you plan to provide lock screen with text updates, add the following Extension element to the Extensions section:
Note:Your application could use multiple extension elements, but consider providing only those, which are really used by the application.
Also note: As the text pulled directly from the application’s primary tile, cyclic tile template shouldn’t be used with LockScreen_Notification_TextField extension as it has no text.
Once application with extensions in manifest deployed to device, user can select the application in Settings/Lock Screen section – application name will be available for selection at notifications sections (detailed and quick status):
Note: the settings should be done by user from Settings menu and cannot be defined form code.
Lock screen Background
In addition to information presented above, Windows Phone 8 application could be then chosen lock screen background provider application, so that application can provide the lock screen background.
To enable this functionality your application must declare additional Extension in application manifest (could be used with or without other lock screen extensions):
Once defined (after deployment) user will be able to choose your application form list of the applications with same functionality on the device:
In addition to this manual method the default lock screen provide could also be changed from code. Let’s see how to request provide lock screen background from code:
The code snippet checks if lock screen already provided by current application, and if not raises request. This request is raised to user as following message box (system provided):
User approval equivalent to Settings change.
Note: user can change this at any time using Settings screen, thus before setting actual background the app should change it it is still current provider.
Now, let’s see how to set lock screen background:
This code snippet verifies that application is still active lock screen background provider and invokes LockScreen.SetImageUri function which changes the background.
In addition, the LockScreen class provides access to current background image URI by LockScreen.GetImageUri function.
New version of Windows Phone Emulator and SDK provides new tool called Simulation Dashboard which enables simulation of various network conditions, lock screen and reminders. This tool located in Tools menu in Visual Studio:
Use radio buttons in Lock Screen section to simulate locking the screen on emulator.
That’s it for now. Next time I will show how to integrate voice recognition into your application.