3
\$\begingroup\$

( I'm not sure if this question belongs here, but since it is related to game development and I have no idea where else I should post this, I will post this here )

As the title says, what I am basically asking is if it is possible to update the livetile of an pure XNA game ( not SL + XNA hybrid )?

I've been thinking something like that whenever user launches the game, I would create an texture dynamically and then update the livetile to show that texture. Even better would be if I could schedule this code to run for example once a day, without requiring user to even launch the game.

Is this possible in WP7 or in WP8 ( is the WP8 SDK even publicly released yet? ) in pure XNA game? What about in XNA + SL hybrid?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ What part of updating isn't working? If you add the Microsoft.Phone.Shell.ShellTile libraries/namespace and follow the standard tutorial (blogs.microsoft.co.il/blogs/pavely/archive/2011/09/30/…) doesn't it work? \$\endgroup\$
    – Roy T.
    Sep 17 '12 at 17:07
  • \$\begingroup\$ Also, the WP8 SDK has only been released yet to people who had WP7 apps on the market, but it will soon be made available to all. \$\endgroup\$
    – Roy T.
    Sep 17 '12 at 17:08
  • \$\begingroup\$ @RoyT. Ahh, thanks. I was aware of Microsoft.Phone.Shell namespace, but I wasn't sure how it could be used since it required Uri of the image, but that article clarified what I have to do. I will update whether I succeed or not. However, I'd still like to know if it is possible to schedule the code that updates the tile to run on a regular basis, without user needing to launch the game. ShellTileSchedule-class doesn't seem to allow to run any code, but rather just wants Uri of the image. \$\endgroup\$
    – user9790
    Sep 17 '12 at 17:20
2
\$\begingroup\$

I managed to update the tile using following code:

public static class ApplicationInfo
{
    public static ShellTile ApplicationLiveTile
    {
        get { return ShellTile.ActiveTiles.FirstOrDefault(); }
    }

    public static void UpdateTile(Texture2D texture)
    {
        const int TextureSize = 173;
        const string FilePath = "/Shared/ShellContent/tile.jpg";

        // Save texture to isolated storage
        IsolatedStorageFile isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
        using (IsolatedStorageFileStream stream = isolatedStorage.CreateFile(FilePath))
        {
            texture.SaveAsPng(stream, TextureSize, TextureSize);
        }

        // Update the tile
        ShellTile tile = ApplicationInfo.ApplicationLiveTile;
        if (tile != null)
        {
            tile.Update(new StandardTileData()
            {
                BackgroundImage = new Uri("isostore:" + FilePath, UriKind.Absolute),
            });
        }
    }
}

I haven't yet tried to make scheduled updating of the live tile as I described in the OP, but it possibly can be done by using Windows Phone Scheduled Task Agent.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy