NewsDroid RSS Reader
Introduction
Welcome to our first tutorial! This tutorial assumes that you are familiar with the official tutorial supplied by Google. If you have not run through that I would highly recommend it!
The syntax highlighting in these tutorials will create hyperlinks to the documentation out of general Java and Android specific classes. So when you see a class like "Activity" in the code you can click on it and be taken to the documentation for that class. Also, the line numbers next to the code correspond to the line numbers in the java files.
In this tutorial we will build a simple RSS reader called "NewsDroid" so that you can get all the headlines without having to hit all your favorite sites in that little browser. The application will open with a list of all of the RSS feeds that you have added, and when a user clicks on a feed then it will display a list of the headlines for that feed. When a user then selects a headline they will be taken directly to that story in the web browser.
This application consists of 7 classes:
- Simple storage classes:
- Article - Simple class to hold the values of an article, ie the the title and url
- Feed - Simple class to hold the values of a feed, ie the title of the feed and url to the XML file
- Backend Classes:
- NewsDroidDB - Handles all the SQL Lite database work
- RSSHandler - Parses RSS feed and saves what we need from them
- Frontend Classes:
- ArticlesList - ListActivity that displays the Articles
- FeedsList - ListActivity that displays the Feeds
- URLEditor - Activity that allows the user to enter the URL for the feed
You may want to download the complete source for reference as you view this tutorial.
On page 2 we discuss the database backend components.
On page 3 we discuss the RSS Parsing using a SAX object.
On page 4 we put it all together with a couple ListActivities and a URL Entry Box
Comments
I tried with the same source code. But it shows an error "The activity FeedURL is not responding.", while entering the url.
What URL are you using? Unfortunately some websites block certain user agents, specifically "java*". For example digg.com blocks any user agents starting with "java". You can use HttpClient object to work around this issue, as it lets you setup the user agent. Sorry for the confusion, for more information on this issue check out this thread.
Post new comment