Search code examples
windows-phonelockscreenwindows-phone-8

Setting lock screen in Windows Phone 8 with a non local image


I am trying to set the lock screen on a Windows Phone 8 using the SetImageUri, but I can't get it to work with a non local image. In my case I have images in a separate assembly, and on a remote server (Azure CDN).

I have already added the manifest entry, and gotten the user permission to be a provider from the sample code.

This is what the code looks like the imageUri would be something like this:

https://infinitecodex.blob.core.windows.net/nflfanapps/26-WALL-1.png

The image exits and is a valid file. I tried putting it in a separate images assembly, and still get this error.

                // At this stage, the app is the active lock screen background provider.
                var uri = new Uri(imageUri, UriKind.Absolute);

                // Set the lock screen background image.
                Windows.Phone.System.UserProfile.LockScreen.SetImageUri(uri);

Everything I try results in an exception:

    Value does not fall within the expected range.

Solution

  • According to this guide you can only use images stored in your Isolated Storage or images packaged with your app:
    Lock screen background for Windows Phone 8
    Nothing stops you from downloading the image to isolated storage and using the Uri to this image as the lockscreen source.

    // At this stage, the app is the active lock screen background provider.// The following code example shows the new URI schema.// ms-appdata points to the root of the local app data folder.// ms-appx points to the Local app install folder, to reference resources bundled in the XAP package.var schema = isAppResource ? "ms-appx:///" : "ms-appdata:///Local/";