• support@answerspoint.com

android.os.NetworkOnMainThreadException

1828

In the below code I got an error when running my Android project for RssReader.

URL url = new URL(urlToRssFeed);
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
XMLReader xmlreader = parser.getXMLReader();
RssHandler theRSSHandler = new RssHandler();
xmlreader.setContentHandler(theRSSHandler);
InputSource is = new InputSource(url.openStream());
xmlreader.parse(is);
return theRSSHandler.getFeed();

And it shows an error:

android.os.NetworkOnMainThreadException

How can I fix this issue?

0Answer


Your Answer

    Facebook Share        
       
  • asked 9 years ago
  • viewed 1828 times
  • active 9 years ago

Best Rated Questions