Home > Tutorials > Creating A Simple RSS Application in Android

Creating A Simple RSS Application in Android

In this tutorial we will build a simple rss application.

Requirements are:
1) parse an rss feed and display the headlines in a ListView
2) when the user clicks on a headline, open the Android browser and redirect to corresponding web page.

Note: this tutorial is outdated. I would suggest you follow the new tutorial. The new tutorial is more extended, but it addresses few issues present in this example. On the other hand, if you are not looking for a very detailed tutorial and are interested only in XML parsing part, feel free to browse this example.

We will parse the PCWorld‘s rss looking for the latest news: http://feeds.pcworld.com/pcworld/latestnews

The final result will look like in the screenshot below:

android rss app

1. Create a new project in Eclipse:
Project: SimpleRssReader
Activity: SimpleRssReaderActivity

2. Add required permissions to AndroidManifest file.
The application will make use of Internet, so this should be specified in the AndroidManifest file, otherwise an exception will be thrown. Just after the <application> tag, (as a child of <manifest> tag), add the following line:

<uses-permission android:name="android.permission.INTERNET"/>

3. Open the main.xml layout file, delete the already existing TextView control, and add instead a ListView with the id “list”. This should should look like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" >

android:layout_height="wrap_content" >


4. Lets create the skeleton of our main activity.
Open the SimpleRSSReaderActivity and make it extend ListActivity, instead of Activity as it  comes by default. We need this in order to display the headlines in the ListView by binding to an array which will hold our data, using the list view adapter.
Add 2 instance variables: “headlines” and “links” of type List.

It should look like this:

public class SimpleRSSReaderActivity extends ListActivity {

	List headlines;
	List links;

	public void onCreate(Bundle savedInstanceState) {


5. In the onCreate() method, just after the setContentView(….) , add following lines:

// Initializing instance variables
headlines = new ArrayList();
links = new ArrayList();

try {
	URL url = new URL("http://feeds.pcworld.com/pcworld/latestnews");

	XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
	XmlPullParser xpp = factory.newPullParser();

        // We will get the XML from an input stream
	xpp.setInput(getInputStream(url), "UTF_8");

        /* We will parse the XML content looking for the "<title>" tag which appears inside the "<item>" tag.
         * However, we should take in consideration that the rss feed name also is enclosed in a "<title>" tag.
         * As we know, every feed begins with these lines: "<channel><title>Feed_Name</title>...."
         * so we should skip the "<title>" tag which is a child of "<channel>" tag,
         * and take in consideration only "<title>" tag which is a child of "<item>"
         * In order to achieve this, we will make use of a boolean variable.
	boolean insideItem = false;

        // Returns the type of current event: START_TAG, END_TAG, etc..
	int eventType = xpp.getEventType();
	while (eventType != XmlPullParser.END_DOCUMENT) {
		if (eventType == XmlPullParser.START_TAG) {

			if (xpp.getName().equalsIgnoreCase("item")) {
				insideItem = true;
			} else if (xpp.getName().equalsIgnoreCase("title")) {
				if (insideItem)
					headlines.add(xpp.nextText()); //extract the headline
			} else if (xpp.getName().equalsIgnoreCase("link")) {
				if (insideItem)
					links.add(xpp.nextText()); //extract the link of article
		}else if(eventType==XmlPullParser.END_TAG && xpp.getName().equalsIgnoreCase("item")){

		eventType = xpp.next(); //move to next element

} catch (MalformedURLException e) {
} catch (XmlPullParserException e) {
} catch (IOException e) {

// Binding data
ArrayAdapter adapter = new ArrayAdapter(this,
		android.R.layout.simple_list_item_1, headlines);


6. In the onCreate() method we passed an input stream to setInput(): xpp.setInput(getInputStream(url), "UTF_8");
getInputStream() is not a standard Java method, so we should create it. This method should take as an argument the feed url, and return the input stream.

public InputStream getInputStream(URL url) {
   try {
       return url.openConnection().getInputStream();
   } catch (IOException e) {
       return null;

7. Finnaly, we want when a title is clicked, the Android browser to be opened and display the corresponding article. This one is simple, we override the onListItemClick() method, get the position of article in the ListView, retrieve the coresponding link, and pass the url of that article to ACTION_VIEW intent which takes care further of displaying the web page.

protected void onListItemClick(ListView l, View v, int position, long id) {
   Uri uri = Uri.parse(links.get(position));
   Intent intent = new Intent(Intent.ACTION_VIEW, uri);

By this time you should compile and run successfully the application.

Well, if everything went fine and you are done with the simple rss application, the next step to consider is how can you enhance the visual aspect of the application. Adding some style to the ListView, for example alternating between background colors, or displaying an icon next to each headline, can considerably increase the visual aspect, which will make your application look more appealing.
Take a look at this tutorial: Building a Custom Fancy ListView in Android, where I show in details how to achieve this.

This application, however, has one major drawback. Its drawback is that all the parsing and network access is done on the UI thread. As a result, you may notice that when starting the application, it “freezes” for a few seconds and then displays the headlines. To fix this issue, you should put all the parsing functionality in a background thread. In regards how to do that, you definitely should consider this post: Understanding AsyncTask – Once and Forever

  1. January 22, 2012 at 7:36 am

    Really helpful blog….Thank you…….

  2. January 22, 2012 at 7:48 am

    I am following your guide but I have some problems..

    ERROR 1:

    if (xpp.getName().equalsIgnoreCase(“item”)) {
    insideItem = true;
    } else if (xpp.getName().equalsIgnoreCase(“title”)) {
    if (insideItem)
    headlines.add(xpp.nextText()); //extract the headline
    } else if (xpp.getName().equalsIgnoreCase(“link”)) {
    if (insideItem)
    links.add(xpp.nextText()); //extract the link of article

    links.add & headlines.add – The method add(R.string) in the type List is not applicable for the arguments (String)

    ERROR 2:

    // Binding data
    ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, headlines);

    The constructor ArrayAdapter(SimpleRssReaderActivity, int, List) is undefined

    ERROR 3:

    protected void onListItemClick(ListView l, View v, int position, long id) {
    Uri uri = Uri.parse(links.get(position));
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);

    Uri.parse – The method parse(String) in the type Uri is not applicable for the arguments (R.string)

    How do I fix this?

    • January 22, 2012 at 9:15 am


      I believe the errors that appear in the program are caused by the improper use of quotes.
      It could be that you copied the source code, or the computer language is not english, and an improper encoding was generated when

      you put them.

      To fix this, manualy change in all equalsIgnoreCase() methods the quotes, from “ ” to ” “.
      (If needed change the computer language to EN – English)

      This should fix as well the ERROR 2, and ERROR 3.

      Later Edit: I see the wordpress does not format the quotes ” ” as they should look. They should look straight, not inclided.

      • hivaibhav@rocketmail.com
        November 11, 2012 at 6:02 pm

        i have tried replacing the quotes manually but the issue remain unresolved..
        plz help..
        plz reply ASAP…

      • lange
        November 20, 2012 at 7:04 pm

        i have no idea if you still look at this thread, but, i have the same error in this line:

        Uri uri = Uri.parse(links.get(position));

        The method parse(String) in the type Uri is not applicable for the arguments (Object) MainActivity.java/RSS-Reader/src/com/rss_reader

        if i just cast it like this:

        Uri uri = Uri.parse((String) links.get(position));
        app is running, till i try to open an item.

        after that the app stopps ….

        any idea why?

      • Rokuzo
        April 11, 2013 at 1:04 pm

        For problem with Uri: change ArrayList headlinks = new ArrayList(); to ArrayList = new ArrayList; and with links do same.

  3. February 15, 2012 at 11:56 am

    very helpful tutorial, but i have some problem with this program, the problem is if there’s no internet connection, the program will have an error and you need to force close it, my question is, how can i program that if there’s no internet connection a dialog box will pop up and says “No internet connection” and it will go back to my Menu. can you please tell me how should i do? thanks a lot :)

  4. February 16, 2012 at 12:04 pm

    Thanks a lot 4 tips

  5. March 19, 2012 at 5:54 am

    can we display headlines and description in a single text box .head lines in bold style and description in normal mode.
    int eventType = xpp.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
    if (eventType == XmlPullParser.START_TAG) {

    if (xpp.getName().equalsIgnoreCase(“item”)) {
    insideItem = true;
    } else if (xpp.getName().equalsIgnoreCase(“title”)) {
    if (insideItem)

    headlines.add(xpp.nextText()); //extract the headline

    }else if (xpp.getName().equalsIgnoreCase(“description”)) {
    if (insideItem)
    headlines.add(xpp.nextText()); //extract the headline
    } else if (xpp.getName().equalsIgnoreCase(“link”)) {
    if (insideItem)
    links.add(xpp.nextText()); //extract the link of article

    headlines.add(xpp.nextText()); //extract the headline
    headlines.add(xpp.nextText()); //extract the description

    please help…. ?

    • March 20, 2012 at 6:31 pm

      You will need to create a new List that will store descriptions, just like we store headlines and links.
      To make the headline and description appear in the same text box, most probably you will need to define a new layout file and then bind this layout file to your ListView. Take a look at this tutorial: Building a Custom Fancy ListView in Android

      To make a text bold, add this property to the corresponding TextView:

  6. March 31, 2012 at 8:32 pm

    nice tutorial as always !!

    but how to grap info from xml of this type?

    • March 31, 2012 at 8:42 pm

      sry i cant post xml code… heres a screen shot

    • March 31, 2012 at 8:47 pm

      I do not understand what you meant. Please explain it, give some more information.

  7. March 31, 2012 at 8:54 pm

    i replied with a picture couse the xml code i posted doesnt show.
    The xml code does not contain a start/end tag , its embedded in one line

  8. March 31, 2012 at 9:15 pm

    That is a document with a self-closing tag,
    and I suppose in this case you need to read the attributes of those tags, for example DBID, EID, and so on. Personally I did not work with files like this yet, but I saw that XMLPullParse has specific methods to work with, like: getAttributeCount();, getAttributeName(), and getAttributeValue().

    However, the topic is interesting, and I’m going to explore it, and eventually writing a post.

  9. March 31, 2012 at 9:27 pm

    ok thanks for the help! gone dig up more about those methods to grap the properties


  10. Dante
    April 4, 2012 at 8:14 pm

    When I run I get this :
    04-04 20:13:36.402: E/AndroidRuntime(580): FATAL EXCEPTION: main
    04-04 20:13:36.402: E/AndroidRuntime(580): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mkyong.android/com.mkyong.android.SimpleRSSReaderActivity}: android.os.NetworkOnMainThreadException
    04-04 20:13:36.402: E/AndroidRuntime(580): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
    04-04 20:13:36.402: E/AndroidRuntime(580): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
    04-04 20:13:36.402: E/AndroidRuntime(580): at android.app.ActivityThread.access$600(ActivityThread.java:123)
    04-04 20:13:36.402: E/AndroidRuntime(580): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
    04-04 20:13:36.402: E/AndroidRuntime(580): at android.os.Handler.dispatchMessage(Handler.java:99)
    04-04 20:13:36.402: E/AndroidRuntime(580): at android.os.Looper.loop(Looper.java:137)
    04-04 20:13:36.402: E/AndroidRuntime(580): at android.app.ActivityThread.main(ActivityThread.java:4424)
    04-04 20:13:36.402: E/AndroidRuntime(580): at java.lang.reflect.Method.invokeNative(Native Method)
    04-04 20:13:36.402: E/AndroidRuntime(580): at java.lang.reflect.Method.invoke(Method.java:511)
    04-04 20:13:36.402: E/AndroidRuntime(580): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    04-04 20:13:36.402: E/AndroidRuntime(580): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    04-04 20:13:36.402: E/AndroidRuntime(580): at dalvik.system.NativeStart.main(Native Method)
    04-04 20:13:36.402: E/AndroidRuntime(580): Caused by: android.os.NetworkOnMainThreadException
    04-04 20:13:36.402: E/AndroidRuntime(580): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
    04-04 20:13:36.402: E/AndroidRuntime(580): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
    04-04 20:13:36.402: E/AndroidRuntime(580): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
    04-04 20:13:36.402: E/AndroidRuntime(580): at java.net.InetAddress.getAllByName(InetAddress.java:220)
    04-04 20:13:36.402: E/AndroidRuntime(580): at libcore.net.http.HttpConnection.(HttpConnection.java:71)
    04-04 20:13:36.402: E/AndroidRuntime(580): at libcore.net.http.HttpConnection.(HttpConnection.java:50)
    04-04 20:13:36.402: E/AndroidRuntime(580): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
    04-04 20:13:36.402: E/AndroidRuntime(580): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
    04-04 20:13:36.402: E/AndroidRuntime(580): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
    04-04 20:13:36.402: E/AndroidRuntime(580): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
    04-04 20:13:36.402: E/AndroidRuntime(580): at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
    04-04 20:13:36.402: E/AndroidRuntime(580): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
    04-04 20:13:36.402: E/AndroidRuntime(580): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
    04-04 20:13:36.402: E/AndroidRuntime(580): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
    04-04 20:13:36.402: E/AndroidRuntime(580): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
    04-04 20:13:36.402: E/AndroidRuntime(580): at com.mkyong.android.SimpleRSSReaderActivity.getInputStream(SimpleRSSReaderActivity.java:92)
    04-04 20:13:36.402: E/AndroidRuntime(580): at com.mkyong.android.SimpleRSSReaderActivity.onCreate(SimpleRSSReaderActivity.java:42)
    04-04 20:13:36.402: E/AndroidRuntime(580): at android.app.Activity.performCreate(Activity.java:4465)
    04-04 20:13:36.402: E/AndroidRuntime(580): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    04-04 20:13:36.402: E/AndroidRuntime(580): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
    04-04 20:13:36.402: E/AndroidRuntime(580): … 11 more

  11. April 6, 2012 at 5:17 am

    Hi there,

    Thanks for the great tutorials. A guide on making a simple rss reader is exactly what I’ve been looking for! I’ve got a couple of issues though:

    I implemented the AsyncTask code from your other guide on this project since I’m writing for the latest version of the SDK which requires you to put all network operations like this. When I run the project it doesn’t seem to show anything. I’m not sure if the information isn’t being downloaded, or it’s not binding to the list items correctly, any ideas?

    Also eclipse is complaining about using the raw type versions of List and ArrayAdapter. Should these be List and ArrayAdapter for generic types?


    • April 6, 2012 at 7:43 am

      Actually I went through debugging, and the rss feed headlines are definitely being stored in the headline list, just not displaying.

      • April 6, 2012 at 10:29 am

        Never mind! I figured it out. The method call to populate the header using the adapter (setListAdapter(adapter)) was happening before the background process could download the rss feed.

        Moving it to the onPostExecute() method of the AsyncTask class sorted it out.

      • April 6, 2012 at 5:52 pm

        I’m glad you figured what’s going on, on your own.

  12. Dante
    April 6, 2012 at 1:55 pm

    @robbiemc : did your RSS app run without the Async class ?
    In other words, I try to run it on Andoid 4.0.3 API Level 15 emulator without the Async class and I got the errors listed above

    • Dante
      April 6, 2012 at 3:33 pm

      Could u help me out and post the PostTask class.

      • April 6, 2012 at 10:34 pm

        Everything between the try and catch clauses went inside the doInBackground method of the AsyncTask class.

        My onPostExecute method inside the same class looks like:

        protected void onPostExecute(String result) {
        adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, _headlines);

  13. Dante
    April 7, 2012 at 5:48 pm

    doInBackground is a method which returns String object
    what do you return ?
    Judging by the article with AsyncTasks , onPostExecute takes as parameter what doInBackground returns

    • Dante
      April 10, 2012 at 7:43 pm

      Nervermind. I figure it out. T.hanks also for the tutorial regarding async tasks. Great tutorial.
      Would definetely recommend it ! Thumbs up

      • April 10, 2012 at 7:44 pm

        Glad that you figured it out!

      • kenneth
        June 29, 2013 at 10:44 am

        plz can you share the code of how you used doInBackground method of the AsyncTask class i hv been trying it for a week now and not working

  14. April 19, 2012 at 8:10 pm

    How do you guys test your code and what IDE are you using ?

    • April 19, 2012 at 8:16 pm

      I use Eclipse as the IDE. The code is tested on the emulator first, then on a real device (usually at the end of development, or at the end of development of a specific piece of funtionallity.)

  15. joseph
    April 22, 2012 at 9:21 am

    very helpfull thanx so much,,,

  16. May 15, 2012 at 7:38 am

    Hy, i have one problem, this is great code, but variable called List doesnt workd for me in java eclipse, please help me,

  17. ngo si loc
    June 3, 2012 at 7:09 am

    I am following your guide but i have error in funtion “setListAdapter(adapter);” i can’t find funtion setListAdapter, can you show me it? thanks for all

  18. alpesh patel
    June 30, 2012 at 8:41 am

    give me clearly information for make news rss feeds or code in android

  19. caroline
    July 9, 2012 at 5:42 pm

    protected void onListItemClick(ListView l, View v, int position, long id) {
    Uri uri = Uri.parse(links.get(position));
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);

    In this method i have received an error on this line:” Uri uri = Uri.parse(links.get(position));”. The error Description

    The method parse(String) in the type Uri is not applicable for the arguments (Object) SimpleRssReaderActivity.java /SimpleRssReader/src/com/SimpleRssReader

    Please assist asap

  20. September 26, 2012 at 7:42 pm

    I have been facing few unexpected problems:
    ArrayAdapter, ArrayList, IOException, MalformedURLException, URL cannot be resolved to a type
    XmlPullParser cannot be resolved
    XmlPullParserException cannot be resolved to a type
    XmlPullParserFactory cannot be resolved
    XmlPullParserFactory cannot be resolved to a type

    Please guide, for I’m a noob

    • October 27, 2012 at 9:30 pm

      You should import their appropriate packages.
      If you are using Eclipse then go to Source -> Organize imports to automatically import all required classes. Or you may use the CTRL+SHIFT+O shortcut which does the same.

  21. September 26, 2012 at 7:53 pm

    Source Code files please, if possible

  22. stargateF
    October 7, 2012 at 1:29 pm

    Thanks a lot for this tutorial !! you just saved my life!

    Indeed i had to create this kind of application for my studies… and i had no idea how to do it!

    Now i understand how to do it and it’s just cool !! thanks a lot for your explanations, they are perfect!!!

    Android and me it’s not a love story i suppose… ^^

  23. Ah Koo
    October 18, 2012 at 10:26 am

    cannot call getInputStream(url) directly (line 13), then I change to
    url.openConnection().getInputStream(). Is this ok?

    • jim
      November 3, 2015 at 7:07 am

      Yeah, it’s not ok!!! i had problem with this method, alway return null, i am using vitual device for this app, Who any else has solution????

  24. Ultimate T
    November 15, 2012 at 9:30 pm

    I have a problem, when I run it on the emulator is just says “Unfortunately SimpleRssReader has stopped” and then shuts down

    • November 20, 2012 at 6:45 pm

      There may be many causes why it crashes, like not declaring the permissions in the AndroidManifest file.
      But I suppose this is because the SimpleRssReader is trying to perform a network operation from the UI thread. In version 2.2 this was possible, but in later versions this is prohibited. You should use an AsyncTask to access the network and parse the RSS.

      • Ultimate T
        November 23, 2012 at 10:29 pm

        Thank you

  25. Michael
    November 18, 2012 at 7:18 am

    I’m having problems with the code in Step 7:
    Multiple markers at this line
    – The method onListItemClick() of type SimpleRssReaderActivity must override a superclass
    – Syntax error on token “1”, invalid VariableDeclaratorId
    – ListView cannot be resolved to a type

    • November 20, 2012 at 6:49 pm

      Make sure your activity extends ListActivity instead of Activity, and import corresponding packages.

      • lange
        November 20, 2012 at 7:05 pm

        if you mean me, yes i extend listactivity… an im running it with version 2.3.3. if this is a case

      • Michael
        November 24, 2012 at 6:23 pm

        It does… I’m very confident that I followed along exactly. I’m really not sure what’s going on or why this isn’t working for me.

  26. November 20, 2012 at 7:33 pm

    lange :
    The method parse(String) in the type Uri is not applicable for the arguments (Object)….

    any idea why?

    Basically this means that Uri.parse() expects a String, but your are giving it an object of another type.
    What I can say is to make sure that when parsing the RSS, you add to the List a String, it
    should be like this: links.add(xpp.nextText());

  27. naruto vs pain tagalog version
    November 23, 2012 at 4:25 am

    Thank you for the good writeup. It in fact was a amusement account it.
    Look advanced to far added agreeable from you! By the way,
    how can we communicate?

  28. December 8, 2012 at 7:23 pm

    Do you mind if I quote a few of your posts as long as I provide credit
    and sources back to your webpage? My website is in the very same niche
    as yours and my visitors would truly benefit from a lot of the information you provide here.
    Please let me know if this ok with you. Cheers!

    • December 8, 2012 at 11:16 pm

      Sure, as long as you refer to the original article it’s OK.

  29. sakis
    January 8, 2013 at 12:15 pm

    the app isn’t runnig for android 4.0.3

    • João
      March 16, 2013 at 6:11 pm

      Didnt work here on android 4.0 friend… :/

      • March 23, 2013 at 3:34 pm

        As I already stated here in comments, the tutorial was built for Android 2.2 and now is a bit outdated. Starting with Android 3.0 you are no longer allowed to perform network operations on the UI thread. If you do, you get a NetorkOnMainThreadException. You should access the RSS from an AsyncTask. That is why on 2.2 works, but on 4.0 crashes.

  30. jishhhh
    January 15, 2013 at 10:45 am

    i have an unknown exception

  31. SCII
    January 22, 2013 at 2:01 am

    #1 Here Thx a lot!

  32. alex
    January 25, 2013 at 4:59 pm

    Hi Andy…thnks…..helpd me in my project….works perfectly

  33. February 5, 2013 at 11:50 am

    Hi, thanks for this tutorial.

    I doing like this instead : list.setOnItemClickListener(new OnItemClickListener() {

    public void onItemClick(AdapterView arg0, View arg1, int position,
    long arg3) {

    Intent intent = new Intent(Playlist.this, PlaySermon.class );



    And its working fine since I wanna play the streamed link in a mediaplayer.

    My problem now is to bring my URL to the other class and send it into the mediaplaying play button. How can I do it?

    Is there anyway to store the URL I have taken out from the xml file into getters or something and use it in the other class.
    I have tried but nothing is working for me.


    • March 23, 2013 at 3:40 pm

      Not sure if I understood your question, but if you want to retrieve the URL from the XML, and then pass it to another method or class, you could put the url into a variable, and then pass that variable to the corresponding method as an argument, or to your class as an argument in constructor.

  34. CJ
    February 14, 2013 at 1:42 pm

    Brilliant tutorial! Works like a charm :) thanks so much!

  35. February 18, 2013 at 8:45 am

    I tried to follow your tutorials but I encountered a runtime exception error that says “Your content must have a ListView who se id attribute is ‘android.R.id.list'”. I’m going nuts even if I changed the ID excactly on what the error said and felt nothing.

  36. February 24, 2013 at 8:23 am

    Thanx a lot for the Post!!! I have a little problm, RSS feed app works perfectly on eclipse simulator , but i can’t run it on my phone , android 4.0 ICS .

    • March 23, 2013 at 3:31 pm

      The tutorial is a bit outdated, starting with Android 3.0 you are no longer allowed to perform network operations on the UI thread. You should access the RSS from an AsyncTask. That is why on 2.3 works, but on 4.0 crashes.

    • Peter John Rajan
      April 3, 2013 at 8:50 am

      U have to select ur Phone’s Android version or below in “Minimum required SDK” at Eclipse

  37. February 24, 2013 at 8:24 am

    it works on AVD 2.3 in simulator

  38. March 6, 2013 at 7:01 pm

    Genuinely no matter if someone doesn’t understand after that its up to other viewers that they will help, so here it happens.

  39. Pratik
    March 7, 2013 at 4:23 pm

    hi, i went through your tutorial step by step and found one error while parsing URL to string…Can u please help me out with this?

  40. Joao
    March 24, 2013 at 5:34 am

    Please update the Tutorial for the latest version of Android. Thank you A LOT friend!!

  41. Andrew
    March 30, 2013 at 5:37 am

    I am new to this so sorry for the stupid question, but when you say “Open the SimpleRSSReaderActivity”, how do I do this?

  42. Peter John Rajan
    April 3, 2013 at 5:38 am

    Code is working perfectly.i got the output.Thank u Andy Res.All u have to do is add this
    try {
    if (android.os.Build.VERSION.SDK_INT > 9) {
    StrictMode.ThreadPolicy policy =
    new StrictMode.ThreadPolicy.Builder().permitAll().build();
    URL url = new URL(“http://feeds.pcworld.com/pcworld/latestnews”);
    List headlines;
    List links;

  43. April 4, 2013 at 9:39 pm

    // Binding data
    ArrayAdapter adapter = new ArrayAdapter(this,
    android.R.layout.simple_list_item_1, headlines);


    how ican connent between list view and this


  44. April 4, 2013 at 11:00 pm

    can u get all filess of project in zip file to download it please

  45. Prithviraj
    April 8, 2013 at 9:28 pm

    First of all thanks for this awesome example it was indeed a gr8 help…for all those who are trying to get it run on API 17 ..all u need to do is first remove the setContentview from the oncreate() method as you will be using one of android’s inbuilt layout..then put all the content of the 5th point under the do in background method of the class extending AsyncTask … then just put the adapter code(i.e //Binding data part ) in the post execute method….lastly for the onclick listener method just modify the URi code as Uri uri = Uri.parse(String(links.get(position))); ..and dats it…..Thanx also to all the people who have replied coz I found my answers by reading through your experiences..M barely a few weeks old to this platform..and you all have been a gr8 help to me…

    • Mike
      April 13, 2013 at 9:19 pm

      I see, so you parse toString?

  46. Mitch V
    April 23, 2013 at 12:30 pm

    The problem I have is specifically this line.


    return type for method is missing and adapter cannot be resolved to a type. Please help thanks.

  47. April 25, 2013 at 3:57 am

    i am getting error in these lines…

    List headlines;
    List links;

    List cannot be resolved a type.

    headlines = new ArrayList();
    links = new ArrayList();

    Multiple markers at this line. List cannot be resolved a type. ArrayList cannot be resolved a type.

    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    XmlPullParser xpp = factory.newPullParser();

    XmlPullParserFactory factory cannot be resolved a type.

    please help. i am new to android development. what are the classes i have to import?

    can you please post the complete “SimpleRssReaderActivity.java ” file…


    • vivek
      July 29, 2015 at 10:11 am

      for your 1st and 2nd query ….
      at the red mark it will give you suggestion and import need lib for type(mostly that will be your 1st suggestion in given list).

      Try This mostly u can solve it by this option.

  48. April 25, 2013 at 7:01 am

    i have used source organized imports. some Errors cleared.

    but still one more error…

    protected void onListItemClick(ListView l, View v, int position, long id) {
    Uri uri = Uri.parse(links.get(position));
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);

    The method parse(String) in the type Uri is not applicable for the arguments (Object)

    Please help.

  49. kajii
    April 26, 2013 at 2:31 pm

    Uri uri = Uri.parse(links.get(position));

    I am getting error on that line
    The method parse(String) in the type Uri is not applicable for the arguments (Object)

    I even did that
    Uri uri = Uri.parse(links.get(position).toString());

    So no build error but runtime error

    how to solve this…

    • April 26, 2013 at 11:39 pm

      As the error says, the method accepts a String but you are passing to it an Object. You would need to cast that object to String.

  50. kajii
    April 26, 2013 at 2:33 pm

    Rokuzo :
    For problem with Uri: change ArrayList headlinks = new ArrayList(); to ArrayList = new ArrayList; and with links do same.

    Still have this error

  51. May 28, 2013 at 6:03 am

    how can i retrieve image from rss feed

  52. June 4, 2013 at 11:50 am

    thanks nice blog

  53. Amit
    June 4, 2013 at 5:30 pm

    I have imported project well in my eclipse and also deploying on the same on my mobile HTC explorer android 2.3 but the install file when try to open i m getting error “Applcation RSSFeeder stopped un-expectedly “…plz help me to sort out this….

  54. June 18, 2013 at 8:28 pm

    Hello, I’m actually using this code to parse the RSS from a website, everything works except that I can’t read descripcion, author o date, only title and link, can it be solved?

  55. Srihari
    July 31, 2013 at 6:10 pm

    I am using the code as given and the app crashes every single time. Any idea to work around?

  56. August 2, 2013 at 5:15 am

    Reblogueó esto en y comentado:
    Add your thoughts here… (optional)

  57. August 6, 2013 at 5:16 pm

    Really helpful tutorial..thanks but….pls solw this

    protected void onListItemClick(ListView l, View v, int position, long id) {
    Uri uri = Uri.parse(links.get(position));
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);

    problem on this code actual news is read but on click not porform…

  58. bpatel
    March 5, 2014 at 12:06 pm

    Thanks for such nice tutorial but I am not able to run it successfully. I could not figure out the error. I tried debug it. I found exception when it tries to set input stream for url. could you please help me. Please find the logcat as below. Thanks you in advance

    03-05 12:03:10.396: I/System.out(1876): libcore.net.http.HttpURLConnectionImpl:http://feeds.pcworld.com/pcworld/latestnews
    03-05 12:03:16.808: D/AndroidRuntime(1876): Shutting down VM
    03-05 12:03:16.808: W/dalvikvm(1876): threadid=1: thread exiting with uncaught exception (group=0xa4bb3648)
    03-05 12:03:16.812: E/AndroidRuntime(1876): FATAL EXCEPTION: main
    03-05 12:03:16.812: E/AndroidRuntime(1876): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.simplerssfeedreader/com.example.simplerssfeedreader.MainActivity}: android.os.NetworkOnMainThreadException

  59. Balaji Sunku
    March 11, 2014 at 1:39 pm

    Nice tutorial.

    I have one question here..

    Lets say we are reading RSS feed from the fallowing url


    Where the description field is truncated with a “…”

    How to read the complete description ???

    Where the fallowing app in google play is able to read it. I am not sure how.


  60. April 23, 2014 at 6:00 am

    Thank you so much .. it’s really helpfull …. i’m very gratefull to you

  61. Phillip
    April 25, 2014 at 6:30 am

    Thanks, and i show someone how to do it ?

  62. May 1, 2014 at 8:02 am

    This article is excellent! I figured out a good deal
    about a whole lot about this!

  63. Veer
    June 13, 2014 at 11:32 am

    How to load headlines and publish date both in listview,any example for same code……

  64. runesh
    July 21, 2014 at 12:59 pm

    Im stuck with the uri parse stuff someone please give an proper detail on how to solve the error…..
    i tried making ArrayList links = ArrayList(); into ArrayList = ArrayList;

    it still gives an error

  65. tung
    July 25, 2014 at 10:48 am

    i do the same it but lose
    07-25 10:39:12.290: E/AndroidRuntime(1258): at com.example.rss.MainActivity.onCreate(MainActivity.java:43)
    07-25 10:39:12.262: I/dalvikvm(1258): Turning on JNI app bug workarounds for target SDK version 10…

    07-25 10:39:12.274: E/Trace(1258): error opening trace file: No such file or directory (2)

    07-25 10:39:12.290: D/AndroidRuntime(1258): Shutting down
    07-25 10:39:12.290: W/dalvikvm(1258): threadid=1: thread exiting with uncaught exception (group=0xa6225288)

    07-25 10:39:12.290: E/AndroidRuntime(1258): FATAL EXCEPTION: main

    07-25 10:39:12.290: E/AndroidRuntime(1258): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.rss/com.example.rss.MainActivity}: android.os.NetworkOnMainThreadException

    07-25 10:39:12.290: E/AndroidRuntime(1258): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at android.app.ActivityThread.access$600(ActivityThread.java:130)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at android.os.Handler.dispatchMessage(Handler.java:99)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at android.os.Looper.loop(Looper.java:137)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at android.app.ActivityThread.main(ActivityThread.java:4745)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at java.lang.reflect.Method.invokeNative(Native Method)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at java.lang.reflect.Method.invoke(Method.java:511)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at dalvik.system.NativeStart.main(Native Method)

    07-25 10:39:12.290: E/AndroidRuntime(1258): Caused by: android.os.NetworkOnMainThreadException

    07-25 10:39:12.290: E/AndroidRuntime(1258): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at java.net.InetAddress.getAllByName(InetAddress.java:214)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at libcore.net.http.HttpConnection.(HttpConnection.java:70)
    7-25 10:39:12.290: E/AndroidRuntime(1258): at libcore.net.http.HttpConnection.(HttpConnection.java:50)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at com.example.rss.MainActivity.getInputStream(MainActivity.java:84)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at com.example.rss.MainActivity.onCreate(MainActivity.java:43)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at android.app.Activity.performCreate(Activity.java:5008)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)

    07-25 10:39:12.290: E/AndroidRuntime(1258): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)

    07-25 10:39:12.290: E/AndroidRuntime(1258): … 11 more

  66. manassharma07
    December 17, 2014 at 8:44 am

    Reblogged this on BragitOff.com and commented:
    Great Article exactly what I needed.
    Anyone who owns a website/blog can create a simple app that will pull own rss feeds from the site. This way you can popularize your site on Android phones.

  67. Chaitendra Pratap
    December 24, 2014 at 7:20 am

    It helped me alot :)

  68. geek_rupak
    December 27, 2014 at 8:24 am

    Reblogged this on and commented:
    Now! Make your own RSS android app.

  69. prasad
    January 12, 2015 at 10:17 am

    its not working for android version 4.0 so what to do to run successfully on version > = 3.0

  70. May 6, 2015 at 8:37 pm

    Good tutorial. I saw some errors, excuseme my english is poor.
    But I solved with this reply http://stackoverflow.com/questions/12485642/android-rss-reader-crashes-at-start-up
    Thanks my friend!.

  71. July 29, 2015 at 9:38 am

    I don’t get any errors in the code, but when I try to launch it, it crashes.
    There are two Solution of this Problem.

    1) Don’t write network call in Main UI Thread, Use Async Task for that.

    2) Write below code into your MainActivity file after setContentView(R.layout.activity_main);

    if (android.os.Build.VERSION.SDK_INT > 9) {
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

    Dipak Keshariya


  72. vivek
    July 29, 2015 at 10:06 am

    07-29 15:04:30.920: E/AndroidRuntime(31218): FATAL EXCEPTION: main
    07-29 15:04:30.920: E/AndroidRuntime(31218): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newsfeed/com.example.newsfeed.MainActivity}: android.os.NetworkOnMainThreadException
    07-29 15:04:30.920: E/AndroidRuntime(31218): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at android.app.ActivityThread.access$700(ActivityThread.java:150)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at android.os.Handler.dispatchMessage(Handler.java:99)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at android.os.Looper.loop(Looper.java:137)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at android.app.ActivityThread.main(ActivityThread.java:5283)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at java.lang.reflect.Method.invokeNative(Native Method)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at java.lang.reflect.Method.invoke(Method.java:511)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at dalvik.system.NativeStart.main(Native Method)
    07-29 15:04:30.920: E/AndroidRuntime(31218): Caused by: android.os.NetworkOnMainThreadException
    07-29 15:04:30.920: E/AndroidRuntime(31218): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1128)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at java.net.InetAddress.getAllByName(InetAddress.java:214)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at libcore.net.http.HttpConnection.(HttpConnection.java:70)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at libcore.net.http.HttpConnection.(HttpConnection.java:50)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:282)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:177)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at com.example.newsfeed.MainActivity.getInputStream(MainActivity.java:105)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at com.example.newsfeed.MainActivity.onCreate(MainActivity.java:47)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at android.app.Activity.performCreate(Activity.java:5283)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
    07-29 15:04:30.920: E/AndroidRuntime(31218): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
    07-29 15:04:30.920: E/AndroidRuntime(31218): … 11 more

    got this type of errors please help me asap.

  73. August 5, 2015 at 4:08 am

    this error has come on it
    08-04 10:10:29.870: E/dalvikvm(838): Could not find class ‘com.fasterxml.jackson.core.JsonFactory’, referenced from method org.npr.android.util.Program$ProgramFactory.downloadPrograms

    08-04 10:10:29.870: W/dalvikvm(838): VFY: unable to resolve new-instance 157 (Lcom/fasterxml/jackson/core/JsonFactory;) in Lorg/npr/android/util/Program$ProgramFactory;

    08-04 10:10:31.400: W/dalvikvm(838): threadid=13: thread exiting with uncaught exception (group=0x40a71930)

    08-04 10:10:31.440: E/AndroidRuntime(838): FATAL EXCEPTION: Thread-91
    08-04 10:10:31.440: E/AndroidRuntime(838): java.lang.NoClassDefFoundError: com.fasterxml.jackson.core.JsonFactory

    08-04 10:10:31.440: E/AndroidRuntime(838):at org.npr.android.util.Program$ProgramFactory.downloadPrograms(Program.java:127)

    08-04 10:10:31.440: E/AndroidRuntime(838): at org.npr.android.news.AllProgramsActivity.constructList(AllProgramsActivity.java:77)

    08-04 10:10:31.440: E/AndroidRuntime(838): at org.npr.android.news.AllProgramsActivity$2.run(AllProgramsActivity.java:109)

    08-04 10:10:31.440: E/AndroidRuntime(838): at java.lang.Thread.run(Thread.java:856)

    thanks in advance..

  74. August 13, 2015 at 1:31 am

    i am creating a app but i need ur little help i want to give my app online support like i want to change the content like photos or text content online like news app it there any way i didn’t find proper words for that plees help sorry for confusing ques

  1. March 17, 2012 at 1:03 pm
  2. February 8, 2013 at 11:00 am
  3. March 23, 2013 at 5:26 am
  4. April 22, 2013 at 3:30 pm
  5. June 1, 2013 at 6:47 pm
  6. March 7, 2015 at 2:59 pm
  7. June 16, 2015 at 4:19 am
  8. July 4, 2015 at 11:43 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 587 other followers

%d bloggers like this: