简体   繁体   中英

How can I add notifications to my news App ANDROID?

I am working on a android news app which gets news from google news rss feed. I am currently getting news and showing it to the user in my app. But I want to show notification to the user when new news appears on google rss. I have no idea how to do it as I am new to android and could not find anything relevant on google. Thank you.

Here is my code I have done so far

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;
        } 

Use parse's push notification,it's very easy to use and has great documents. https://parse.com

go for push notification service. its the only way to get the notification .

follow this tutorial... http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

Notification manager is what you want here.

see this http://developer.android.com/guide/topics/ui/notifiers/notifications.html ?

A simple google search also shows tutorials for the same

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM