简体   繁体   中英

Updating live tile in Windows Phone 8.1 Offline

I have managed to create a live tile for my app using the following code:

        var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText01);

        var tileImage = tileXml.GetElementsByTagName("image")[0] as XmlElement;
        tileImage.SetAttribute("src", "ms-appx:///Assets/Icon.png");

        var tileText = tileXml.GetElementsByTagName("text");
        (tileText[0] as XmlElement).InnerText = ""+DateTime.Now.ToString();
        (tileText[1] as XmlElement).InnerText = "1";
        (tileText[2] as XmlElement).InnerText = "2";
        (tileText[3] as XmlElement).InnerText = "3";

        var tileNotification = new TileNotification(tileXml);
        TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

However I am not sure how to make the live tile update automatically using a scheduler agent. I have looked at using TileUpdateManager.StartPeriodicAgent however it requires a URI parameter and I would like to avoid creating a Server just to update my live tile.

Is there a way I can do this? Thanks a lot :D

You need to run a background agent from your app and put your live tile update code there.

MSDN on the topic:

Quickstart: Update a live tile from a background task

Background agents/multitasking on Windows Phone 8.1:

http://www.jayway.com/2014/04/23/windows-phone-8-1-for-developers-multitasking-and-background-tasks/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM