Asynctask causes a fatal error while executing the Ackground() method

Asked

Viewed 155 times

3

The code does not present any error, but when I run it stops and presents a Fatal error at runtime in the Asyncloadxmlfeed class extending from Asynctask.

follows the class code Asyncloadxmlfeed that is inside Splashactivity

public class AsyncLoadXMLFeed extends AsyncTask<Void, Void, Void> {

    public AsyncLoadXMLFeed() {

    }


    @Override
    protected Void doInBackground(Void... params) {

        //Obtem o feed
        DOMParser myParser = new DOMParser();
        feed = myParser.parseXml(RSSFEEDURL);
        if(feed != null && feed.getItemCount() > 0)
            WriteFeed(feed);            
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        super.onPostExecute(result);

        startLisActivity(feed);
    }

}

private void WriteFeed(RSSFeed data) {

    FileOutputStream fOut = null;
    ObjectOutputStream osw = null;

    try {
        fOut = openFileOutput(fileName, MODE_PRIVATE);
        osw = new ObjectOutputStream(fOut);
        osw.writeObject(data);
        osw.flush();
    } catch (Exception e) {
        e.printStackTrace();
    }
    finally{
        try {
            fOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
  • 2

    Just saying it’s wrong and not saying what it is Doesn’t help who might want to help you.

  • Agree with @ramaral, it would be good to take a look at the logcat to see if there is no stacktrace of the error that occurred.

1 answer

-1

Guys, find the error.

There was a library that I referenced to, but the jar file wasn’t in the bin folder. Ai when the project was compiled the library was not packaged in apk. Dai gave the error.

Solution: was to copy the file to the bin folder and refresh it and then clear and refresh the whole project.

Thanks!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.