Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Use Java's SAXParser to retrieve and parse an RSS feed for Android. This Java tip is for developers new to Android and includes instructions for setting up an Android development environment and a short application tutorial.
An RSS feed is an XML-formatted file used to publish periodically updated syndicated information. An RSS feed may be parsed (that is, read and formatted) using an XML parser. Java-compatible parsers used to parse XML on Android include:
android.content.res.XmlResourceParser is a pull parser
org.xml.sax package
This Java tip is a step-by-step introduction to using the javax.xml.parsers.SAXParser to parse an RSS feed in XML format. SAXParser is a standard choice because it is included with the Android APIs in the Android
SDK. We'll set up the development environment, create a simple Android app and feed for demonstration purposes, and then use
SAXParser to format the feed for Android. While some familiarity with Java application development is assumed, this tip is
suitable for developers new to Java mobile development.
Take the following steps to set up the development environment for this project:
We'll create an example Android project to receive the RSS feed.
Activity class (RssFeed).
Note that an activity (Step 6) represents a user interaction. The class extending the Activity class creates a window for a UI.
The resulting Android project will consist of the following files:
RSSFeed), which extends Activity.
In res/layout/main.xml, specify the layout of the Android UI components. Create a LinearLayout and set android:orientation as "vertical." Our goal is to display the RSS feed as a text message, so add a TextView element for the title of the RSS feed and specify android:text as a Google RSS Feed. Add a TextView element, with id "rss" to display the RSS feed. Listing 1 shows the resulting main.xml.
Learn more about Android.
More from JavaWorld