tags:

views:

361

answers:

2

I want to make an app which (amongst other things) can parse feeds loaded via the network. Given that the standard Anrdoid + Core Java libraries do not provide a feed parser service and I dont want to write a one myself, can you nominate a Java feed parser which will work on a low-spec Android device.

I'm just starting out learning Android, having completed the Hello World examples I'd like to move onto my first app. I want to make something which prarses some ATOM or RSS feeds and displays some content in a GridView.

The UI stuff seems to be very well documented in Android, and Sun have plenty of examples of how to retrieve a URL, however I'm not so how to do the feed parsing.

Previously when I've done this sort of thing in Pythion I use a general purpose feed parser which can parse pretty much anything (e.g. RSS, ATOM). There are plenty of good Python implementations of this sort of thing, however I've not found anything like this as part of the standard Android library.

At work I've done (light) maintenance on corporate java apps. The general practice seems to be to take whatever classes you like (e.g. the Jakarta Commons feed-parser) and simply bundle them into the CLASSPATH. Desktop apps do not care how big the dependancies are, however I'm sure that's a big issue when compiling an APK bundle for use on a device with limited meory. Surely I have to be very picky about what kind of Jars I depend on, right? Can I just go ahead and use the same classes that I'd use for desktop apps?

Notes:

  • My background is in Python (with only light Java experience)
  • Ideally I'd like to use something popular (not neccecarily the best) so I can get support on it.
  • Even better, I'd like to use built in library functionality so I dont have to add any 3rd party Jars to bloat my app.
  • Currently targeting Android 1.5 (because that's what my device runs)
+2  A: 

Since RSS/Atom feeds are essentially XML documents you can use SAXParser, which is part of the standard Java libraries included with Android.

James
Yes, I could do this - but I'd much rather not re-invent the wheel. Surely many (much more tallented developers than I) have already created perfectly good feed-parsers. If I were developing for the desktop I'd never hand code a feed parser from SAX, it would probably be rubbish given my time constraints. Can I do something similar for Android?
Salim Fadhley
Either use a third party library or re-invent the wheel. Since you said you didn't want to bundle third party jars with your app, using SAX would be the best route. If you want to use other RSS libraries then I would go with Bozho's suggestion of using Rome.
James
Clarification, I want to minimize additional dependancies, as they cause bloat, however it's probably better to add a little fat and make it better than spend most of my time implementing basic/boring stuff like feed parsers. See my comment below re Rome
Salim Fadhley
+1  A: 

Rome appears to be one of the most popular java RSS libraries. I guess it can be used on Android too.

Bozho
I've read that Rome requires JavaBeans which is not a component on the Android platform. It's probably not an option.
Salim Fadhley
I remember seeing a project for android RSS which was based on Rome. It was inactive, though. So give Rome a try, it shouldn't take long to realize whether it works or not. Anyway, search Stackoverflow for more on this matter - there are lots of results.
Bozho
ClassLoader isn't supported by Android's DalvikVM, witch is used in the ROME api.
lemotdit