如何在我的新闻应用中添加通知?

本文关键字:添加 通知 应用 新闻 我的 | 更新日期: 2023-09-27 18:19:04

我正在一个安卓新闻应用程序,从谷歌新闻rss源获取新闻。我目前正在获得新闻,并在我的应用程序显示它的用户。但我想显示通知给用户,当新的新闻出现在谷歌rss。我不知道如何做到这一点,因为我是新的安卓和无法找到任何相关的谷歌。谢谢你。

这是我到目前为止所做的代码

internal static List<FeedItem> GetFeedItems(string url)
        {
            List<FeedItem> feedItemsList = new List<FeedItem>();
            try
            {
                HttpClient wc = new HttpClient();
                var html = wc.GetStringAsync(new Uri(url)).Result;

                XElement xmlitems = XElement.Parse(html);
                // We need to create a list of the elements
                List<XElement> elements = xmlitems.Descendants("item").ToList();
                // Now we're putting the informations that we got in our ListBox in the XAML code
                // we have to use a foreach statment to be able to read all the elements 
                // Description  , Link , Title are the attributes in the RSSItem class that I've already added
                List<FeedItem> aux = new List<FeedItem>();
                foreach (XElement rssItem in elements)
                {
                    FeedItem rss = new FeedItem();
                    rss.Description = rssItem.Element("description").Value;
                    rss.Link = rssItem.Element("link").Value;
                    rss.Title = rssItem.Element("title").Value;
                    feedItemsList.Add(rss);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return feedItemsList;
        } 

如何在我的新闻应用中添加通知?

使用parse的推送通知,它非常容易使用,并且有很棒的文档。https://parse.com

选择推送通知服务。这是获得通知的唯一方法。

遵循本教程…http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

通知管理器就是你想要的。

看这个http://developer.android.com/guide/topics/ui/notifiers/notifications.html ?

一个简单的谷歌搜索也显示相同的教程