Tips to handle live tile update in background task

When implementing a UWP application, a separate background task could be used to update live tile. In this post, I am going to cover some scenarios that tile update doesn't work or doesn't work as expected, hope this can save your troubleshooting time.

If any template with image in TileTemplateType such as TileSquare150x150PeekImageAndText01, is used to build a tile, while the tile can't be updated successfully, check whether the images are 200k or less in size and 1024x1024 pixels or smaller which is mentioned in https://msdn.microsoft.com/en-us/library/dn439794(v=vs.85).aspx .

If the images meet the requirement while the tile still can't be updated successfully, the issue might not be related to the app itself.
Go to Settings->Privacy->Background apps, make sure background task is enabled for the app.
Go to Settings->System->Battery, make sure Battery saver is turned off, otherwise background will be disabled to extend battery life.

Background tasks are expected to execute lightweight task, thus limited by the amount of wall-clock usage time they get based on trigger type. Most triggers are limited to 30 seconds of wall-clock usage such as TimerEvent. If the background task is busy to run longer than 30 seconds, it will be terminated silently just as below, which means the code to update tile could not be executed yet.

2016-10-23

Probably you have multiple tiles and would like them flip one. While, if notification queue is not enabled, the tiles will just flip and stop at the last tile without fliping anymore. This is designed behavior, in order to make them flip all the time, call TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true) before updating the tiles.

Though same background task handler can be triggered by different events, you can't make it as the below snippet code, because the second builder.SetTrigger will just simply override the first one. In order to support multiple trigger events, construct separate BackgroundTaskBuilder for every single trigger event.
builder.SetTrigger(new SystemTrigger(SystemTriggerType.SessionConnected, false)); builder.SetTrigger(new TimeTrigger(15, false));

If the tiles are correctly updated, the designed behavior is the tiles will "flip" one by one to catch the user's attention; after some time, the animation will change to "slide" from bottom to up. Finally, the animation will stop at the last tile if the start screen is still there. Notice that the animation is enabled by default in Settings->Ease Of Access->Other options->Play animations in Windows. If the animation is disabled, the tiles will update one by one without any animation and this is the default behavior in remote desktop.

Comments

  • Anonymous
    October 23, 2016
    Awesome man thanks a lot.