Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

I/System.out: ep: android.os.NetworkOnMainThreadException

class RetrieveFeedTask extends AsyncTask<String, Void, RSSFeed> {

    private Exception exception;

    protected RSSFeed doInBackground(String... urls) {
        try {
            URL url = new URL(urls[0]);
            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();
        } catch (Exception e) {
            this.exception = e;

            return null;
        } finally {
            is.close();
        }
    }

    protected void onPostExecute(RSSFeed feed) {
        // TODO: check this.exception
        // TODO: do something with the feed
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java print line 
Java :: how to clear scoreboard with offline players java 
Java :: get bimap by uri in android 
Java :: code converter python to java 
Java :: jersey get session time 
Java :: comparable interface 
Java :: java += 
Java :: linked list introduction 
Java :: java unused import statement 
Java :: spring core xml configuration for collection using constructor 
Java :: tests offline cypress 
Java :: data base spring 
Java :: test spring cloud stream 
Java :: build cmake gradle 
Java :: open google maps cycling navigation 
Java :: Rotate Left k cells java 
Java :: javax big int validation in spring boot 
Java :: Small Change 
Java :: convert object address to string in java 
Java :: change FS to hdfs java 
Java :: batch file to switch between java version 
Java :: Java Super Power java 
Java :: java.lang.ArrayIndexOutOfBoundsException: 4 
Java :: song listening app android 
Java :: executors java 
Java :: findview by id in android 
Java :: java android join array list 
Java :: java jcombobox selected item changed 
Java :: how to add a number to the ascii value of a char in java 
Java :: how to find a string in a sentence in java 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =