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 8350759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:25:25+00:00 2026-06-09T08:25:25+00:00

I’m trying to build an android RSS reader app but I keep getting a

  • 0

I’m trying to build an android RSS reader app but I keep getting a Null pointer exception. I’m new to java and can’t tell if its the feed url not returning any data or the data not being stored properly.

my logcat reads:

08-08 18:44:25.840: E/Trace(621): error opening trace file: No such file or directory (2)
08-08 18:44:25.910: W/ActivityThread(621): Application com.app.fullmetalmanga is waiting for the debugger on port 8100...
08-08 18:44:25.930: I/System.out(621): Sending WAIT chunk
08-08 18:44:25.951: I/dalvikvm(621): Debugger is active08-08 18:44:26.140: I/System.out(621): Debugger has connected
08-08 18:44:27.710: I/System.out(621): debugger has settled (1382)
08-08 18:44:29.291: D/gralloc_goldfish(621): Emulator without GPU emulation detected.
08-08 18:44:48.060: W/System.err(621): java.lang.NullPointerException
08-08 18:44:48.760: W/System.err(621):  at java.util.Calendar.setTime(Calendar.java:1324)
08-08 18:44:48.810: W/System.err(621):  at java.text.SimpleDateFormat.formatImpl(SimpleDateFormat.java:536)
08-08 18:44:49.050: W/System.err(621):  at java.text.SimpleDateFormat.format(SimpleDateFormat.java:821)
08-08 18:44:49.150: W/System.err(621):  at java.text.DateFormat.format(DateFormat.java:376)
08-08 18:44:49.490: W/System.err(621):  at com.app.fullmetalmanga.RssItem.getDate(RssItem.java:48)
08-08 18:44:49.810: W/System.err(621):  at com.app.fullmetalmanga.MainActivity$RSSHandler.endElement(MainActivity.java:146)
08-08 18:44:50.090: W/System.err(621):  at org.apache.harmony.xml.ExpatParser.endElement(ExpatParser.java:156)
08-08 18:44:50.250: W/System.err(621):  at org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
08-08 18:44:50.410: W/System.err(621):  at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
08-08 18:44:50.610: W/System.err(621):  at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
08-08 18:44:50.791: W/System.err(621):  at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
08-08 18:44:50.990: W/System.err(621):  at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
08-08 18:44:51.800: W/System.err(621):  at com.app.fullmetalmanga.MainActivity$SAXHelper.parseContent(MainActivity.java:112)
08-08 18:44:51.870: W/System.err(621):  at com.app.fullmetalmanga.MainActivity$loadingTask.doInBackground(MainActivity.java:74)
08-08 18:44:52.350: W/System.err(621):  at com.app.fullmetalmanga.MainActivity$loadingTask.doInBackground(MainActivity.java:1)
08-08 18:44:52.700: W/System.err(621):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
08-08 18:44:53.070: W/System.err(621):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-08 18:44:53.190: W/System.err(621):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-08 18:44:53.370: W/System.err(621):  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
08-08 18:44:53.561: W/System.err(621):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-08 18:44:53.980: W/System.err(621):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-08 18:44:54.051: W/System.err(621):  at java.lang.Thread.run(Thread.java:856)

And my main activity:

public class MainActivity extends Activity {
/** Called when the activity is first created. */
ListView lv1;
ProgressDialog ShowProgress;
public ArrayList<RssItem> RssItemList = new ArrayList<RssItem>();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    lv1 = (ListView) findViewById(R.id.listView1);

    ShowProgress = ProgressDialog.show(MainActivity.this, "",
            "Loading. Please wait...", true);
    new loadingTask().execute("http://fandom.com/rss/news/manga");

    lv1.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {

            Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri
                    .parse(RssItemList.get(position).getTitle()));
            startActivity(intent);

        }
    });       
}


class loadingTask extends AsyncTask<String, Void, String> {

    protected String doInBackground(String... urls) {

        SAXHelper sh = null;
        try {
            sh = new SAXHelper(urls[0]);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        sh.parseContent("");
        return "";

    }

    protected void onPostExecute(String s) {
        lv1.setAdapter(new EfficientAdapter(MainActivity.this, RssItemList));
        ShowProgress.dismiss();

    }
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}




class SAXHelper {
public HashMap<String, String> userList = new HashMap<String, String>();
private URL url2;

public SAXHelper(String url1) throws MalformedURLException {
    this.url2 = new URL(url1);
}

public RSSHandler parseContent(String parseContent) {
    RSSHandler df = new RSSHandler();
    try {

        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();
        XMLReader xr = sp.getXMLReader();
        xr.setContentHandler(df);
        xr.parse(new InputSource(url2.openStream()));
    } catch (Exception e) {
        e.printStackTrace();
    }
    return df;
}
}


class RSSHandler extends DefaultHandler {

private RssItem currentPost = new RssItem();
StringBuffer chars = new StringBuffer();

@Override
public void startElement(String uri, String localName, String qName,
        Attributes atts) {

    chars = new StringBuffer();
    if (localName.equalsIgnoreCase("item")) {

    }
}

@Override
public void endElement(String uri, String localName, String qName)
        throws SAXException {

    if (localName.equalsIgnoreCase("title")
            && currentPost.getTitle() == null) {
        currentPost.setTitle(chars.toString());

    }
    if (localName.equalsIgnoreCase("pubDate")
            && currentPost.getDate() == null) {
        currentPost.setDate(chars.toString());

    }
    /*if (localName.equalsIgnoreCase("thumbnail")
            && currentPost.getThumbnail() == null) {
        currentPost.setThumbnail(chars.toString());

    } */
    if (localName.equalsIgnoreCase("link")
            && currentPost.getLink() == null) {
        currentPost.setLink(chars.toString());
    }

    if (localName.equalsIgnoreCase("item")) {
        RssItemList.add(currentPost);
        currentPost = new RssItem();
    }

}

@Override
public void characters(char ch[], int start, int length) {
    chars.append(new String(ch, start, length));
}

   }

}

My RssItem Class:

public class RssItem {

static SimpleDateFormat FORMATTER = 
        new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z");
    private String title;
    private URL link;
    private String description;
    private Date date;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title.trim();
    }
    // getters and setters omitted for brevity 
    public URL getLink() {
        return link;
    }

    public void setLink(String link) {
        try {
            this.link = new URL(link);
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description.trim();
    }

    public String getDate() {
        return FORMATTER.format(this.date);
    }

    public void setDate(String date) {
        // pad the date if necessary
        while (!date.endsWith("00")){
            date += "0";
        }
        try {
            this.date = FORMATTER.parse(date.trim());
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }


}

My code was made using this example. Changing only the URL and using my own modified “Post” file. (Renamed RssItem)

  • 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-09T08:25:26+00:00Added an answer on June 9, 2026 at 8:25 am

    It appears that date in RssItem in null, when you pass it to your SimpleDateFormat the exception is thrown:

    public String getDate() {
        return FORMATTER.format(this.date); // FORMATTER cannot format a null value
    }
    

    You need to define a default date or other polite method of handling this:

    public String getDate() {
        if(this.date == null)
            return "";
        return FORMATTER.format(this.date);
    }
    
    • 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
We're building an app, our first using Rails 3, and we're having to build
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
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
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

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.