Hello guys I am trying to make this RSS Android App to work but I am having some problems since I am just a beginer at this. Also sorry if the errors are not included yet, I am going to update it asap. I am downloading my eclipse since it got corrupted. :(
The following is the code I am using:

SimpleRSSReaderActivity.java

package com.example.simplerssreader;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;


import org.xmlpull.v1.XmlPullParser;

import org.xmlpull.v1.XmlPullParserException;

import org.xmlpull.v1.XmlPullParserFactory;


import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;


public class SimpleRSSReaderActivity<List> extends ListActivity {

List headlines;
List links;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);        
 // Initializing instance variables
    headlines = new ArrayList();
    links = new ArrayList();

    try {
        URL url = new URL("");

        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.

        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) {

Main.java

package com.example.simplerssreader;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

 public class Main extends Activity {

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >


</LinearLayout>

Dani AI

Generated

Common problems in the pasted files explain why the app won’t run yet. As asked, include the exact LogCat stacktrace when available — the fixes below address the typical compile/runtime errors seen with that code: an incorrect class declaration/generic, missing ListActivity import, undefined helper method getInputStream(...), wrong charset string, missing INTERNET permission, doing network I/O on the UI thread, no adapter/ListView hookup, and not closing streams.

Fixes to apply (minimal, concrete):

  • Remove the stray generic from the activity declaration and import the right class:
    public class SimpleRSSReaderActivity extends ListActivity
  • Use typed collections (avoid raw List) and set an adapter so the list actually shows items:
    List<String> headlines = new ArrayList<String>();
    setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, headlines));
  • Ensure the layout contains a ListView with the id Android expects if you use a custom layout:
    <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" />
  • Add the permission in AndroidManifest.xml:
    <uses-permission android:name="android.permission.INTERNET" />

Networking and parsing notes:

  • Replace the undefined helper call with a proper stream from the URL (and use the correct charset string "UTF-8"), and always close the stream in finally or try-with-resources.
  • Do the fetch/parse off the main thread (AsyncTask, Executor, IntentService, etc.). Minimal pattern:
    new AsyncTask<URL,Void,List<String>>(){ protected List<String> doInBackground(URL...u){ /* openConnection(), parse */ } protected void onPostExecute(List<String> r){ setListAdapter(...); }}.execute(url);

Troubleshooting checklist: check LogCat for the exact exception (NetworkOnMainThreadException, MalformedURLException, IOException, XmlPullParserException), include full stacktrace when posting, confirm the launcher activity in AndroidManifest, and test on a device/emulator with network access.

Can you please explain what errors you're experiencing?

Also, I detagged this thread from daniweb-api. I had thought you were using DaniWeb's API, but you are using PC World's.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.