• support@answerspoint.com

android.os.NetworkOnMainThreadException

472

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 3 years ago
  • viewed 472 times
  • active 3 years ago

Hot Questions