How to fix 'android.os.NetworkOnMainThreadException'?

0 like 0 dislike
13 views

I got an error while 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);

by (550 points) | 13 views

1 Answer

0 like 0 dislike

This exception is thrown when an application attempts to perform a networking operation on its main thread. Run your code in AsyncTas

by (1.2k points)

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
1,107 users