Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9084923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:07:13+00:00 2026-06-16T21:07:13+00:00

I followed a simple tutorial (http://www.cse.nd.edu/courses/cse40814/www/RSS_Android.pdf) to read RSS feed from a given URL

  • 0

I followed a simple tutorial (http://www.cse.nd.edu/courses/cse40814/www/RSS_Android.pdf) to read RSS feed from a given URL into a listView. I have added the INTERNET permission and the code is error free in Eclipse but it will not show any RSS feed when launched on a device or emulator. I can’t make the code anymore simpler, and the feed I am using is stable feed from http://www.nba.com : http://www.nba.com/rss/nba_rss.xml though i have tested it on several RSS feeds and with still no feed showing.

Any ideas guys?

Main.java

package com.android.simplerssreader;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.android.simplerssreader.data.RssItem;
import com.android.simplerssreader.util.RssReader;

public class Main extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    try {

        RssReader rssReader = new RssReader(
                "http://www.nba.com/rss/nba_rss.xml");
        ListView Items = (ListView) findViewById(R.id.listView1);

        ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(this,
                android.R.layout.simple_list_item_1, rssReader.getItems());

        Items.setAdapter(adapter);
        Items.setOnItemClickListener(new ListListener(rssReader.getItems(),
                this));

    } catch (Exception e) {
        Log.e("SimpleRssReader", e.getMessage());
    }

}
 }

ListListener.java

package com.android.simplerssreader;

import java.util.List;

import com.android.simplerssreader.data.RssItem;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

public class ListListener implements OnItemClickListener {

List<RssItem> listItems;
Activity activity;

public ListListener(List<RssItem> listItems, Activity activity) {
    this.listItems = listItems;
    this.activity = activity;
}

public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {

    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(listItems.get(pos).getLink()));
    activity.startActivity(i);

}

}

RssItem.java

package com.android.simplerssreader.data;

public class RssItem {
private String title;
private String link;
public String getTitle() {
    return title;
}
public void setTitle(String title) {
    this.title = title;
}
public String getLink() {
    return link;
}
public void setLink(String link) {
    this.link = link;
}

}

RssParseHandler.java

package com.android.simplerssreader.util;

import java.util.ArrayList;
import java.util.List;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

import com.android.simplerssreader.data.RssItem;

public class RssParseHandler extends DefaultHandler {

private List<RssItem> rssItems;

private RssItem currentItem;
private boolean parsingTitle;
private boolean parsingLink;

public RssParseHandler() {
    rssItems = new ArrayList<RssItem>();
}

public List<RssItem> getItems() {
    return rssItems;
}

@Override
public void startElement(String uri, String localName, String qName,
        Attributes attributes) throws SAXException {
    if ("content-item".equals(qName)) {
        currentItem = new RssItem();
    } else if ("title".equals(qName)) {
        parsingTitle = true;
    } else if ("url".equals(qName)) {
        parsingLink = true;
    }
}

@Override
public void endElement(String uri, String localName, String qName)
        throws SAXException {
    if ("content-item".equals(qName)) {
        rssItems.add(currentItem);
        currentItem = null;
    } else if ("title".equals(qName)) {
        parsingTitle = false;
    } else if ("url".equals(qName)) {
        parsingLink = false;
    }
}

@Override
public void characters(char[] ch, int start, int length)
        throws SAXException {
    if (parsingTitle) {
        if (currentItem != null)
            currentItem.setTitle(new String(ch, start, length));
    } else if (parsingLink) {
        if (currentItem != null) {
            currentItem.setLink(new String(ch, start, length));
            parsingLink = false;
        }
    }
}

}

RssReader.java

package com.android.simplerssreader.util;

import java.util.List;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import com.android.simplerssreader.data.RssItem;

public class RssReader {

private String rssUrl;

public RssReader(String rssUrl) {

    this.rssUrl = rssUrl;
}

public List<RssItem> getItems() throws Exception {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser saxParser = factory.newSAXParser();

    RssParseHandler handler = new RssParseHandler();
    saxParser.parse(rssUrl, handler);
    return handler.getItems();
}
}

main.xml

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

<ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000"
    android:cacheColorHint="#FFA500"
    android:scrollingCache="false"
    android:textColor="#ADD8E6" >
</ListView>

</LinearLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.simplerssreader"
android:versionCode="1"
android:versionName="1.0" >

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

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="16" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.android.simplerssreader.Main"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

LogCat

01-04 16:22:16.171: E/SimpleRssReader(8685): Couldn’t open http://www.nba.com/rss/nba_rss.xml

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:07:14+00:00Added an answer on June 16, 2026 at 9:07 pm

    replace

    Log.e("SimpleRssReader", e.getMessage());
    

    with

    Log.e("SimpleRssReader", e.getMessage(), e);
    

    you lose the stack trace information.

    BTW, your error is that you can’t access the network in Android when you are inside the UI Thread (after HoneyComb) : How to fix android.os.NetworkOnMainThreadException?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed this tutorial on creating a simple rss reader... http://www.kieranmcgrady.com/blog/2012/4/25/tutorial-how-to-create-a-simple-rss-reader-for-ios.html The problem is
I followed the tutorial from this site: http://theappleblog.com/2008/08/04/tutorial-build-a-simple-rss-reader-for-iphone/ to make my first iPhone application,
This is probably very simple! I followed a tutorial from http://webdesignerwall.com/demo/jquery-sequential/jquery-sequential-list.html It works fine
I followed the simple tutorial @ http://www.devart.com/dotconnect/oracle/articles/Tutorial_EF.html (Which works perfectly, btw) combined with http://www.hanselman.com/blog/CreatingAnODataAPIForStackOverflowIncludingXMLAndJSONIn30Minutes.aspx
I'm developing simple CUDA app. I followed steps given on http://www.ademiller.com/blogs/tech/2010/10/visual-studio-2010-adding-intellisense-support-for-cuda-c/ but still there
I have followed the tutorial at: http://www.15seconds.com/issue/040331.htm for making a BHO, however i doesnt
I've followed this tutorial and it works fine: http://www.dynamicdrive.com/style/csslibrary/item/css-popup-image-viewer/ However my problem is that
I have followed the tutorial: www.edumobile.org/iphone/iphone-programming-tutorials/a-simple-stopwatch-for-iphone and I get 1 error and 1 warning,
I followed the Simple OmniAuth tutorial ( http://asciicasts.com/episodes/241-simple-omniauth ), and I can log in
I followed this tutorial http://www.ibm.com/developerworks/java/tutorials/j-jni/section2.html (C implementation) for implementing a simple example of JNI

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.