WP7 Development Tip of the Day: Using ShellTileSchedule to update your app’s Live Tile background

by brad 24. November 2010 13:35

About Live Tiles

Live Tiles are called Live Tiles for good reason: they are more than just a boring picture.  You can do lots of things with live tiles, including updating the background image, changing the title, and displaying a count.

About ShellTileSchedule

This tip focuses on one way you can update your app’s live tile background: The ShellTileSchedule.  Of the two ways to update the background image, ShellTileSchedule is by far the easiest.  The other mechanism is a push notification.

To start, you need to get the background image you will use for your background on a web server.  ShellTileSchedule can only pull images off the web, not from the phone itself.  This is one of the limitations of ShellTileSchedule.  If you want to set background images to resources on the phone, look at using push notifications instead.

The Code

Once you have your image on the web, setting up a schedule to update it is as simple as executing this code when your application launches

   1: var url = "http://www.codebadger.com/photoservice/random";
   2: var schedule = new ShellTileSchedule
   3:                     {
   4:                         Interval = UpdateInterval.EveryHour,
   5:                         MaxUpdateCount = 10,
   6:                         Recurrence = UpdateRecurrence.Interval,
   7:                         RemoteImageUri = 
   8:                         new Uri(url),
   9:                         StartTime = DateTime.Now
  10:                     };
  11: schedule.Start();

This will register a new update schedule with the phone.  In this particular example, we’re making a call to a pretend web service that returns a different random image every time it’s called. This provides a convenient way to get different images to the phone without code changes.

This schedule changes the image every hour and will quit updating the image after 10 updates.  If the code executes again (like when your app runs again), the count starts over.

Gotchas

  • The image will not update immediately.  Give it an hour or so before you suspect that you did something wrong.
  • The image will update both in the emulator and on the real phone, so you can test in either.
  • The image must be 80KB max and have a download time of less than 15 seconds.
  • Tiles won’t update if the phone is locked

Other Resources

More Tips

Tags:

WP7 Tip of the Day | Windows Phone

Comments

11/25/2010 1:20:13 PM #

pingback

Pingback from topsy.com

Twitter Trackbacks for
        
        WP7 Development Tip of the Day: Using ShellTileSchedule to update your app’s Live Tile background
        [codebadger.com]
        on Topsy.com

topsy.com

Comments are closed

About Brad

Brad Tutterow lives in Illinois and works in Missouri. He has 12 years of experience developing web sites and Windows applications using a variety of technologies and is most excited currently about Silverlight, Windows Phone 7, Halo Reach, and Visual Studio 2010.