Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

( 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?

share|improve this question
1  
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? –  Roy T. Sep 17 '12 at 17:07
    
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. –  Roy T. Sep 17 '12 at 17:08
    
@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. –  Jaakko Lipsanen Sep 17 '12 at 17:20
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.