AndroidPub
Published in

AndroidPub

Build A BBC World News Aggregator App In 35 Minutes — Building Android App Series

I want to quickly walk you through how to build a BBC world news aggregator app on Android. The app will make use of the BBC RSS feed to display the news content.

Final product

Let me quickly state that I do not work for or represent BBC. The BBC world news is used just as an example, you can plug in your favorite news source as a replacement.

I have created a video lesson on Youtube where I walkthrough every step in details.

Video lesson

The app will be written in the beloved Kotlin. It will be a very simple app which you can easily add additional features on top. I will be making use of two awesome services which are:

  1. Zapier: Zapier is a service that allows you to automate several things. For this project, we will be using Zapier to store any new news item in the BBC news feed in our Firebase database.
  2. Firebase: We will be using the Firebase Realtime Database to save news item in the BBC news feed.

First things first, fire up Android studio and click on New Project. You can give the project any name, but I will be calling it VeryQuickNewsAggregator. Leave all the default options checked and click Next.

While creating the project, make sure you select the option to create a new empty activity. I will be calling that activityMainActivity and it’s going to be the default launcher activity.

Newer versions of Android Studio comes with a tool which you can use to easily integrate Firebase into your application. The tool can be accessed by going to the Tools menu at the top and clicking on Firebase. You should get a screen like this.

There are several really good Firebase services, but for this app, we are only interested in the Realtime Database. Click on Save and retrieve data link under the Realtime Database option. There are two steps you have to take to setup the Firebase database for the app:

  1. Click on the button below Connect your app to Firebase. When the dialog comes up, select an existing project or create a new one.
  2. Click on the button below Add the Realtime Database to your app. It should add the needed dependencies to your build.gradle files.

If you completed the steps listed above, you should get a screen very similar to the one below.

With Firebase setup, let’s add the needed dependencies to our app build.gradle file. We will be adding the following libraries:

  1. RecyclerView: We will be using it to show the list of news items.
  2. Picasso: A simple image loading library which we will be using to load the news thumbnail.
  3. EasyFirebaseList: A library that will help us easily show a list of items from the Firebase database.
  4. FinestWebView: A custom WebView we will be using to display the news item detail.

The app build.gradle file should look like this.

The FinestWebView installation guide states that the FinestWebViewActivity needs to be added to the app AndroidManifest file. Also, we need to request the INTERNET permission to be able to connect to the internet. So our AndroidManifest.xml file will look like this.

The MainActivity will just be hosting a single fragment, so we can modify the activity_main layout file to include the simple FrameLayout below.

We will need to create a layout file that shows each news item in a RecyclerView. Create a new layout called item_news . It will just be a very simple horizontal LinearLayout that contains a TextView that shows the news title and an ImageView that displays the news thumbnail.

We can now create a new Fragment that will handle the display of news items. I will name the new Fragment as NewsListFragment, but feel free to use any name here. If you are using the Android studio GUI to create the Fragment, ensure you uncheck all the checkboxes (use the image below as a guide).

Let’s now add the code to show this newly created Fragment in our MainActivity class.

We need to create a model for the news data that will be stored in the Firebase database. We will be using Kotlin Data class which saves us from writing several boilerplate methods like getters and setters.

Next is to create a RecyclerView.ViewHolder for the news items. Thanks to Kotlin Android Extension, we don’t need to add any findViewById calls here. We only have a very simple bind function that binds the data to the views.

Finally, let’s add the main ingredient which is the NewsListFragment. We will be making use of the EasyFirebaseList library to easily show a list of items from the Firebase database. The library handles showing progress, empty and error states. The implementation of the NewsListFragment is pretty straightforward.

The last step is to use Zapier to automate the reading and saving of the BBC world news RSS feed items to the Firebase database.

We will need to create a new ZAP (task) on Zapier. Zaps are automations created using one Trigger and one Action. So tasks are made of two important components:

  1. Trigger: A Trigger is any event that sets your Zap in motion. Some examples of Triggers include a new favorited Tweet on Twitter, a new email in Gmail, or a new note in Evernote.
  2. Action: An Action is an event that’s completed in a second app automatically. Some examples of Actions include appending text to a note in Evernote, adding a new spreadsheet row in a Google Doc, or creating a new card in Trello.

If you are new to Zapier, you can easily create a new account. After login, click on Make A Zap button (It’s located at the top with an orange background). When the page loads up, search for the RSS app and select it.

After selecting the RSS app, click on the continue button. Select the single option that shows up when the next page loads up and click on Continue again.

The next screen is where you specify the RSS feed URL. We will be using the BBC world news RSS feed URL here. Leave every other field unchanged and click on Continue

The final step for the RSS feed trigger is to test it to ensure Zapier can actually access the RSS feed. After successfully testing it, click on Continue to create a new Action.

We want to insert each new news item into the Firebase database. So for the action, search for Firebase, select it and click on Continue.

The next screen will prompt you to select an action. We will select the Create Child Record action and click on Continue.

In the next screen, you will have to setup the Firebase child record. Use the image below as a guide or you can watch the video lesson (included at the top of this post).

After setting up the Firebase child record, click on Continue. The next and final step will be to test the Firebase database. After doing that you can click on Finish which will create a new ZAP in your Zapier account. Don’t forget to give your ZAP a name and switch it ON.

You can now install the app on an emulator or real device and run it. It should display the data currently in the Firebase Realtime Database. As Zapier adds more items to the database, it will get automatically updated on the app.

So, that’s it. You have successfully created a news aggregator app. If you have any question, please leave a comment below and I will reply as soon as possible. You can view the project Repository on Github.

If you enjoyed this story, please click the 👏 button and share to help others find it! Also feel free to leave a comment below.

--

--

--

The (retired) Pub(lication) for Android & Tech, focused on Development

Recommended from Medium

Deploy Interactive Real-Time Data Visualizations on Flask With Bokeh

Bokeh, Flask, and Easybase logos joined by plus signs

How to Learn Data Science Interactively with Python?

Delete a Job From Your Chainlink Node

Using Service Subscription (HTTP/2) to Retrieve Device Status

AWS Code Guru — Salvation to your Code

The memory and the processes

How I started learning html.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Elvis Chidera

Elvis Chidera

https://elvischidera.com

More from Medium

BookLogApplication: Connecting the dots with more logic

Custom Notification with Work manager for Android

Android 13: Notification Runtime Permission

👨🏼‍💻Guide for Using Cloud DB with Hilt