Android and RSS

12:58 PM , , 5 Comments

Recently, I was working on a simple Android application for an upcoming independent singer - the concept was simple, it was going to be an app with three different pages:

  1. Latest News - this was going to just be an RSS feed of the artists site to get all the latest info
  2. Watch Videos - this was going to be the artists youtube channel embeded
  3. Latest Tweets - this was going to be the artist's tweets (like any good upcoming artist they were making full use of social media channels)

Embedding youtube into android was going to be straight forward (both Google), and from my experience creating Zippy, my Twitter application, the tweets list was going to be easy, so the only work really was to create the RSS feed. Easy I thought..


A quick Google for Java RSS libraries threw up ROME - so I went about constructing all the necessary parts so ROME could plugin and feed me the info i needed to create a JSON list for my list view. However, on plugging it all together and trying to get ROME to work on my Android emulator it just wasn't playing nicely, so again back on Google and I found this discussion on StackOverflow - it turns out that ROME along with some other RSS parsers don't work on Android on account of incompatible packages on the Dalik JVM.


Being fairly frustrated at this point I decided to go back to basics and just implement my own RSS parser based on SAX - I found a tutorial here on a complete RSS parser Android application, so I was able to use some of that for the boiler plate stuff, but there were some issues with the parser not working correctly (not correctly handling the "characters" values in endElement()) but I have managed to get it working and creating a simple Android RSS reader - you can get the complete code here: (also on my source code example list to the left)

The code is an Eclipse project, you can just import this into your workspace and (as long as Android is correctly set up) run the application and you will see a simple RSS stream from my blog!

5 comments:

  1. Hi,

    Thanks for posting this tutorial. It has helped me design a working RSS reader in Android.

    Can you explain how to allow the user to change the URL being used as the feed?

    ReplyDelete
  2. Hi, glad it was helpful.

    The current URL is defined in the the RssReader class in the getLatestRssFeed() method - If you look at this code you will see that the URL is hardcoded in a String - I would just change that method so it is getLatestRssFeed(String url) - that way when you call the method you can just pass in any string needed.

    ReplyDelete
  3. It doensn't work for me. I installed the apk but I got a black screen from my eclipse android emulator. I got the name of the application at the top, then a black screen. Any idea ? I put the permission in my manifest.xml file.

    ReplyDelete
  4. @arno I think the feed that's hardcoded in the sample may be broken. I changed it to a known good feed and it worked fine.

    ReplyDelete
  5. i like your articles so much. please try to post them more frequently.

    ReplyDelete