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

  • SEARCH
  • Home
  • 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 7962127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:14:50+00:00 2026-06-04T05:14:50+00:00

I’ve followed this tutorial but when I try to run the application I get

  • 0

I’ve followed this tutorial but when I try to run the application I get “Unfortunately RSSPro has stopped.”

This is my code for the RSSProActivity:

package com.android.rss;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;

import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class RSSProActivity extends ListActivity {

    ArrayList<String> headlines;
    ArrayList<String> links;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


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

        try {
            URL url = new URL("http://www.bom.gov.au/fwo/IDZ00059.warnings_vic.xml");

            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            factory.setNamespaceAware(false);
            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")){
                    insideItem=false;
                }

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

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

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

    }

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

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

}

My main.xml looks like this:

<?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:orientation="vertical" >

<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>

</LinearLayout>

LogCat messages:

05-21 19:44:40.528: D/dalvikvm(528): Not late-enabling CheckJNI (already on)
05-21 19:44:41.716: I/dalvikvm(528): threadid=3: reacting to signal 3
05-21 19:44:41.726: I/dalvikvm(528): Wrote stack traces to '/data/anr/traces.txt'
05-21 19:44:41.946: D/dalvikvm(528): GC_FOR_ALLOC freed 87K, 3% free 9136K/9347K, paused 113ms
05-21 19:44:41.956: I/dalvikvm-heap(528): Grow heap (frag case) to 9.904MB for 960016-byte allocation
05-21 19:44:42.056: D/dalvikvm(528): GC_CONCURRENT freed 1K, 3% free 10072K/10311K, paused 6ms+14ms
05-21 19:44:42.176: D/dalvikvm(528): GC_FOR_ALLOC freed 0K, 3% free 10072K/10311K, paused 38ms
05-21 19:44:42.196: I/dalvikvm-heap(528): Grow heap (frag case) to 11.963MB for 2160016-byte allocation
05-21 19:44:42.217: I/dalvikvm(528): threadid=3: reacting to signal 3
05-21 19:44:42.306: I/dalvikvm(528): Wrote stack traces to '/data/anr/traces.txt'
05-21 19:44:42.316: D/dalvikvm(528): GC_CONCURRENT freed 0K, 2% free 12181K/12423K, paused 3ms+4ms
05-21 19:44:42.526: D/gralloc_goldfish(528): Emulator without GPU emulation detected.
05-21 19:44:48.076: I/dalvikvm(528): threadid=3: reacting to signal 3
05-21 19:44:48.206: D/AndroidRuntime(528): Shutting down VM
05-21 19:44:48.206: W/dalvikvm(528): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
05-21 19:44:48.216: I/dalvikvm(528): Wrote stack traces to '/data/anr/traces.txt'
05-21 19:44:48.396: E/AndroidRuntime(528): FATAL EXCEPTION: main
05-21 19:44:48.396: E/AndroidRuntime(528): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.rss/com.android.rss.RSSProActivity}: android.os.NetworkOnMainThreadException
05-21 19:44:48.396: E/AndroidRuntime(528):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-21 19:44:48.396: E/AndroidRuntime(528):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-21 19:44:48.396: E/AndroidRuntime(528):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-21 19:44:48.396: E/AndroidRuntime(528):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-21 19:44:48.396: E/AndroidRuntime(528):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-21 19:44:48.396: E/AndroidRuntime(528):  at android.os.Looper.loop(Looper.java:137)
05-21 19:44:48.396: E/AndroidRuntime(528):  at android.app.ActivityThread.main(ActivityThread.java:4424)
05-21 19:44:48.396: E/AndroidRuntime(528):  at java.lang.reflect.Method.invokeNative(Native Method)
05-21 19:44:48.396: E/AndroidRuntime(528):  at java.lang.reflect.Method.invoke(Method.java:511)
05-21 19:44:48.396: E/AndroidRuntime(528):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-21 19:44:48.396: E/AndroidRuntime(528):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-21 19:44:48.396: E/AndroidRuntime(528):  at dalvik.system.NativeStart.main(Native Method)
05-21 19:44:48.396: E/AndroidRuntime(528): Caused by: android.os.NetworkOnMainThreadException
05-21 19:44:48.396: E/AndroidRuntime(528):  at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
05-21 19:44:48.396: E/AndroidRuntime(528):  at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
05-21 19:44:48.396: E/AndroidRuntime(528):  at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
05-21 19:44:48.396: E/AndroidRuntime(528):  at java.net.InetAddress.getAllByName(InetAddress.java:220)
05-21 19:44:48.396: E/AndroidRuntime(528):  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
05-21 19:44:48.396: E/AndroidRuntime(528):  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
05-21 19:44:48.396: E/AndroidRuntime(528):  at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
05-21 19:44:48.396: E/AndroidRuntime(528):  at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
05-21 19:44:48.396: E/AndroidRuntime(528):  at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
05-21 19:44:48.396: E/AndroidRuntime(528):  at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
05-21 19:44:48.396: E/AndroidRuntime(528):  at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
05-21 19:44:48.396: E/AndroidRuntime(528):  at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
05-21 19:44:48.396: E/AndroidRuntime(528):  at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
05-21 19:44:48.396: E/AndroidRuntime(528):  at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
05-21 19:44:48.396: E/AndroidRuntime(528):  at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
05-21 19:44:48.396: E/AndroidRuntime(528):  at com.android.rss.RSSProActivity.getInputStream(RSSProActivity.java:92)
05-21 19:44:48.396: E/AndroidRuntime(528):  at com.android.rss.RSSProActivity.onCreate(RSSProActivity.java:48)
05-21 19:44:48.396: E/AndroidRuntime(528):  at android.app.Activity.performCreate(Activity.java:4465)
05-21 19:44:48.396: E/AndroidRuntime(528):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-21 19:44:48.396: E/AndroidRuntime(528):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-21 19:44:48.396: E/AndroidRuntime(528):  ... 11 more
05-21 19:44:48.616: I/dalvikvm(528): threadid=3: reacting to signal 3
05-21 19:44:48.708: I/dalvikvm(528): Wrote stack traces to '/data/anr/traces.txt'
05-21 19:44:49.116: I/dalvikvm(528): threadid=3: reacting to signal 3
05-21 19:44:49.206: I/dalvikvm(528): Wrote stack traces to '/data/anr/traces.txt'
05-21 19:44:49.436: I/dalvikvm(528): threadid=3: reacting to signal 3
05-21 19:44:49.476: I/dalvikvm(528): Wrote stack traces to '/data/anr/traces.txt'
05-21 19:44:56.997: I/Process(528): Sending signal. PID: 528 SIG: 9

I’m currently using the SDK 15 version (Android 4.0.3). My codes can be compiled in Eclipse but couldn’t run on the emulator. What is it that I’m doing wrong?

  • 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-04T05:14:51+00:00Added an answer on June 4, 2026 at 5:14 am

    You are facing the NetworkOnMainThreadException because of retrieving the XML in main thread. Use AsyncTask to perform the fetching and parsing of XML in background. A sample can be found in: Read RSS in background, using AsyncTask

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.