Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7059211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:12:18+00:00 2026-05-28T04:12:18+00:00

I have an AsyncTask which is executed just before my application quits. It gets

  • 0

I have an AsyncTask which is executed just before my application quits. It gets the location and also parses my layout xml file. The location is retrieved but the parsing doesn’t get executed.

Calling AsyncTask in my Main Activity:

public void quitApplication()
    {       
        FinishProcess fProcess = new FinishProcess();
        fProcess.execute(this);
}

AsyncTask:

public class FinishProcess extends AsyncTask<Main, Void, Void>
{
    @Override
    protected Void doInBackground(Main... params) {
        LocationHandler lh = new LocationHandler();
        try {
            lh.getLocationSingle(null, params[0]);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        parseXML(params[0]);
        return null;
    }

    private void parseXML(Main params)
    {
        String ANDROID_ID = "android:id";       
        Resources resources = params.getResources();

        try {
            InputStream fXmlFile = resources.openRawResource(R.raw.pages);

            //Reads xml file and gets the node types and attributes
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(fXmlFile);

            doc.getDocumentElement().normalize();
            NodeList nList = doc.getElementsByTagName("*");

            for (int temp = 0; temp < nList.getLength(); temp++) {
                Node nNode = nList.item(temp);   
                if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                    Element eElement = (Element) nNode;
                    System.out.println(eElement.getNodeName());
                }
            }

        } 
        catch (Exception e) {
            System.out.println("Catch");
            e.printStackTrace();
        }

    }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:12:18+00:00Added an answer on May 28, 2026 at 4:12 am

    If your application is quitting after starting this process, then perhaps the main thread is dying while the background one (AsyncTask) is running, thereby orphaning it. If this needs to be done during shutdown try doing it in Application.onTerminate without the AsyncTask thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have MainActivity which does some Work before it Executes an AsyncTask called Datensammlung.
I have an AsyncTask which gets called onCreate() in my Main Activity . In
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have a common class say for eg Class A which extends AsyncTask and
I have a service, that requests another class, which launches an AsyncTask Service->Weather Class->Execute
I have to download a file and I'm using this code , which is
I have a large data file, which is zipped, and approximately 20MB. When it's
I have created an application having tab activity which in turn has 5 different
I have an AsyncTask which calls my LocationHandler class method getLocation() which runs a
I have a backgorund thread that extends AsyncTask and which I use in activity

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.