Written by Stoyan Rachev
I recently created Feeder, a fully functional yet simple Android RSS Feed Reader application. Although I wrote it for an internal contest at SAP, my main goal was to explore and showcase best Android programming practices in areas such as content providers, asynchronous processing, data binding, custom views and adapters, background services, and advanced UI features.
- Subscribe and unsubscribe to RSS and Atom feeds.
- View feeds and feed entries as picture mosaics rather than plain lists.
- Conveniently navigate between feeds and feed entries.
- Refresh feeds with a button click and in the background.
- Read feeds offline.
- View featured entries that contain one or more predefined keywords.
- Clean old feed entries with a button click.
- Uses the Android port of Rome for parsing RSS and Atom feeds.
- Uses ORMLite for simple annotation-based persistence of Java objects.
- Feeds and their entries are exposed via a content provider, so they can be accessed also from other applications. The provider implementation is based on a mini-framework which saves a lot of boilerplate code.
- All operations on data such as querying the content provider, performing database operations, and downloading feeds from the Internet are performed asynchronously in background threads.
- Uses custom views managed via data binding for lists of feeds and their entries in order to display them as picture mosaics.
- There is a background service for refreshing the feeds on a regular interval.
- On Android 3.0 or higher, makes use of advanced UI features such as action bars.
For more highlihts, as well as known issues / TODOs, see Feeder’s Wiki.
The Content Provider Framework
Perhaps the most interesting programming highlight in Feeder is the Content Provider Framework. It enables you to create a fully functional Android content provider with much less code than when using the standard approach. Behind the scenes, the framework uses database functionality and metadata information provided by ORMLite and a few additional custom annotations to build content queries and manage database tables in a generic way.
At the moment, this framework is part of the Feeder application, so it cannot be readily used in other applications. If there is enough interest, I will extract it into its own open source project, or integrate it into an existing one such as android-annotations.
Using this framework is as simple as following these two trivial steps:
1. In your data model entity classes, extend Data and add a few annotations such as @UriPaths, @MimeType, and @DefaultSortOrder.
2. To create your content provider, extend AbstractContentProvider and override its onCreate() method to configure it appropriately.
And that’s it. If you have written Android content providers in the standard way, you should be missing here a few hundred lines more of boilerplate code. All this is largely replaced by the functionality available in the framework AbstractContentProvider and DatabaseHelper classes.
For more information on this mini-framework, see it’s dedicated Wiki page.