Skip to main content

skip to main content

developerWorks  >  Open source  >

Create BlackBerry applications with open source tools, Part 2: Building an RSS reader

developerWorks
Page 1 of 9 Go to the next page

Document options
PDF format - Fits A4 and Letter

PDF - Fits A4 and Letter
262 KB (31 pages)

Get Adobe® Reader®

Sample code


My developerWorks needs you!

Connect to your technical community


Rate this tutorial

Help us improve this content


Level: Intermediate

Frank Ableson, Author

17 Feb 2009

In the same way that open source has revolutionized the software development marketplace, the proliferation of alternative news sources has shaken up the traditional news-source monopolies. Today, you can get free news from various Internet sources and from the Internet outlets of the mainstream media. Trekking from one Web site to another to read news stories is possible, but tedious. And what about updates to news stories of interest? Wouldn't it be better if the news of interest is aggregated for your convenience? You can do it with an RSS reader for BlackBerry. Here in Part 2 of this "Create BlackBerry applications with open source tools" series, explore the RSS data-distribution format by creating a BlackBerry RSS reader suitable for taking news wherever you and your BlackBerry go.

Before you start

This series explores open source and Java™ technology for BlackBerry application development in the context of a mobile data-collection application. Part 1 provides an introduction to BlackBerry development with a quick introduction to the platform, a tour of the BlackBerry development tools, and construction of a complete data-collection application.

This tutorial focuses on BlackBerry application development using an example of a mobile content-management application. The example demonstrates a basic RSS reader leveraging the freely available BlackBerry development tools. Mobile development experience is helpful, but not required. Java programming skills are required for BlackBerry applications, but are not an explicit requirement for this tutorial. RSS feeds are the source of the data content used by the sample application. Familiarity with RSS is helpful, but not required if you just want an understanding of a mobile content-management application architecture.

About this tutorial

Why be concerned about writing an RSS reader for BlackBerry? The BlackBerry, and all cell phones, are an integral part of life today. Our mobile devices have increasingly functional user interfaces (UIs) and increased technical capabilities in terms of data rates, storage capacity, and processor speed. But if there is no content to enjoy on these mobile powerhouses, the devices are of marginal use beyond the phone. We need content on our devices. Remember "The pen is mightier than the sword?" The written word matters. And today, the written word is digital — and mobile. The free flow of information and the freedom to subscribe to news of interest is the foundation of a free and open society. What better application of open source technology than an RSS reader to subscribe to free sources of information?

This tutorial uses the Java programming language to build a mobile news reader for the BlackBerry platform. There are commercial RSS readers for mobile devices, but it is not the objective of this tutorial to compete with the commercial applications. This tutorial shows how to build an open source application to help you build useful applications centered on content and its distribution. Learn about managing RSS feeds representing news items from a variety of sources. You can use this same paradigm in other applications, such as mobile fleet-management data, worker-dispatch data, or even implementing a mobile search engine.

Though it's a popular platform, third-party applications are still needed for the BlackBerry. There is no better way to bring those applications to fruition than to enable the open source community. Follow along as this tutorial lays the groundwork for an open source RSS reader application, which you can readily expand and retool for other useful purposes.

This tutorial provides a brief introduction to RSS, then dives into the requirements for a mobile RSS reader for BlackBerry. You can download the complete source code for the BlackBerry application.



Back to top


System requirements

This tutorial demonstrates how to use BlackBerry development tools to construct an open source RSS reader for BlackBerry. You will need the BlackBerry Java Development Environment (JDE) or equivalent to construct the application. This tutorial uses V4.0.2 of the JDE. The tutorial includes a few sample RSS feed links, but you can substitute your own links as desired.

Sample code highlights

In this tutorial, a mobile RSS reader application named IBMRss is constructed for the BlackBerry. As you go through, try to think beyond a news reader; the RSS data format can be leveraged for many other applications. You can download the full source code. Source-code snippets include:

IBMRssApplication
The application class that contains the entry point of the application.
IBMRssScreen
Class containing the UI elements, including menus and a ListField. Provides user interaction functions.
IBMRssStorage
Class that encapsulates the storage of data, including various access/helper routines.
setupdata
Method responsible for organizing the relationship between the stored data and the user interface. Used at startup and after the RSS feeds are refreshed.
loadFeed
Method that presents the entries from a specific RSS feed when selected in the UI.
showItem
Method that displays a specific RSS item's description and presents an option to view the Full Story.
RSSDescription
Class invoked by showItem to display a specific RSS item.
RssKeyListener
Class responsible for interacting with the BlackBerry's keyboard. It looks for the Enter and Esc keys.
drawListRow
Method responsible for drawing the text for the ListField, which is used to display the RSS data. A single ListField is used for displaying a collection of RSS feeds and listing the items in a specific RSS feed.
IBMRssXMLHandler
Class that extends the DefaultHandler class to handle the parsing events generated by the SAX XML parser engine, which is used to parse the RSS feeds.
IBMRssComms
Class responsible for fetching all of the RSS feeds when desired. Extends the java.lang.Thread class.
Guid
Class containing some final members useful for communicating across threads and for uniquely identifying the application's data store.
Utils
Class containing a single method of interest: split. This implements a simple tokenizer for processing data stored in our RecordStore (implemented by IBMRssStorage).



Back to top



Page 1 of 9 Go to the next page