我正在开发一个android新闻应用程序,它可以从谷歌新闻rss订阅中获取新闻。我目前正在获取新闻,并在我的应用程序中向用户显示它。但我想在google rss上出现新新闻时向用户显示通知。我不知道怎么做,因为我是android的新手,在google上找不到任何相关的东西。谢谢。
以下是我到目前为止所做的代码
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;
}
发布于 2015-10-23 14:27:53
使用parse的推送通知,它非常容易使用,并且有很棒的文档。https://parse.com
发布于 2015-10-23 14:15:41
转到推送通知服务。这是获得通知的唯一方法。
按照本教程..。http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
发布于 2015-10-23 14:15:56
在这里,通知管理器就是你想要的。
看到这个http://developer.android.com/guide/topics/ui/notifiers/notifications.html了吗?
简单的google搜索也会显示相同的教程
https://stackoverflow.com/questions/33295852
复制相似问题