locked
Help Geting Data from a RSS Feed and Displaying on a Live Tile

    Question

  • Hi

    Im cusomizing a app created on AppStudio that gets data from a RSS feed. The app is working, geting data and displaying on the app. The problem is with the Live Tile. I have created a Shared Class between my Windows 8 App and Windows Phone 8 App called TileDataSource. Below is the code for this:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using AppStudio.Services;
    
    namespace AppStudio.Data
    
    {
        public class TileDataSource : IDataSource<RssSchema>
        {
    
            private const string _url = @"http://rss.com/feed";
    
            private IEnumerable<RssSchema> _data = null;
    
            public TileDataSource()
            {
            }
    
            public async Task<IEnumerable<RssSchema>> LoadData()
            {
    
                if (_data == null)
                {
                    try
                    {
                        var rssDataProvider = new RssDataProvider(_url);
                        _data = await rssDataProvider.Load();
    
                    }
                    catch (Exception ex)
                    {
                        AppLogs.WriteError("TileDataSourceDataSource.LoadData", ex.ToString());
                    }
                }
    
    
                return _data;
    
    
            }
    
            public async Task<IEnumerable<RssSchema>> Refresh()
            {
                _data = null;
                return await LoadData();
            }
    
        }
    }

    And after that im customizing the TileService Class to get the data from the RSS feed but no success. Here is the Code for the TileService Class:

    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text;
    using System.Threading.Tasks;
    
    using Windows.Data.Xml.Dom;
    using Windows.UI.Notifications;
    
    using AppStudio.Services;
    using AppStudio.Data;
    using System.Diagnostics;
    
    
    
    namespace AppStudio.Services
    {
        public class TileServices
        {
    
    
            static public void CriaTileLargo(string Titulo, string Imagem)
            {
    
    
                // Limpa o Tile
                Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Clear();
    
    
                try
                {
                    // wide 310x150
                    // Cria o Xml do Tile
                    XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150ImageAndText02);
    
                    // Cria a variavel do títlo do Tile a atribui valor a essa variavel
                    XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
                    tileTextAttributes[0].InnerText = Titulo;
    
                    // Cria a variavel da imagem do Tile e atriui valor a essa variavel
                    XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image");
                    ((XmlElement)tileImageAttributes[0]).SetAttribute("src", Imagem);
                    ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic");
    
                    // Cria a notificação do Live Tile
                    TileNotification tileNotification = new TileNotification(tileXml);
                    tileNotification.ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10);
                    TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
    
                    
    
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
    
                }
    
            }
        }
    }

    I know that im not referecing the TileDataSource class on the TileService Class. I removed that code because i know its wrong. I want to know how to implement it.

    Another thing i need help is how can i get the live tile updating on the background.

    Can some one please help me?

    Monday, May 19, 2014 2:18 PM

All replies

  • Hi Fabio - there are multiple tile samples on the sample site:

    http://code.msdn.microsoft.com/windowsapps/site/search?query=tile&f%5B0%5D.Value=tile&f%5B0%5D.Type=SearchText&ac=4

    Have you reviewed these?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, May 20, 2014 12:36 PM
    Moderator
  • But that its not the problem i have. I just dont know how to use the TileDataSource Class to retrieve the RSS data for the live Tile. Can you give me a litle help?


    Sory about my bad english.
    Wednesday, May 21, 2014 5:46 PM