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 7164781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:07:55+00:00 2026-05-28T14:07:55+00:00

I need to parse an xml file which takes about 3 seconds, and immediately

  • 0

I need to parse an xml file which takes about 3 seconds, and immediately use the data that is parsed from the xml file after it has completed. However, since it takes around 3 seconds to complete, i don’t just want the screen sitting and waiting for 3 seconds showing nothing. I would like it to display a ProgressDialog. I’ve tried everything in these threads and while most do 2 / 3, none seem to do all 3.

Basically I have a button that when pressed, i want to parse the xml file and then use the data parsed from the file:

void onButtonClicked() {

    ProgressDialog pd = new ProgressDialog(this);
    pd.setMessage("Parsing...");
    pd.show();
    String[] ret;
    return = parseXmlFile();
    pd.dismiss();
    if (ret[0] == "steve") {
       sayHiToSteve();
    }
}  

If I use an asyncTask, it will continue on with execution and check ret[0] before the task is completed and will just be null.
if i do AsyncTask.get(), it pauses the execution but doesn’t display the progress dialog, so that’s no good either.

I also looked at creating a seperate thread, but i had the same problem. I can’t use a timer, because it is about 3 seconds (but can be up to 4 or 5 seconds if connection is slow), so i can’t approximate.

Any help is much appreciated.
Thanks in advance.

  • 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-28T14:07:56+00:00Added an answer on May 28, 2026 at 2:07 pm

    You can use an AsyncTask for this, something like:

    public class ParseXMLTask extends AsyncTask<Void, Void, String[]>
    {
    
        private ProgressDialog dlg;
    
        @Override
        protected void onPostExecute(String[] result)
        {
            dlg.dismiss();
            if (result[0] == "steve")
            {
                sayHiToSteve();
            }
    
            super.onPostExecute(result);
        }
    
        @Override
        protected void onPreExecute()
        {
            dlg = new ProgressDialog(MyActivity.this);
            dlg.setMessage("Parsing...");
            dlg.setCancelable(false);
            dlg.setIndeterminate(true);
            dlg.show();
    
            super.onPreExecute();
        }
    
        @Override
        protected String[] doInBackground(Void... params)
        {
            return parseXmlFile();
        }
    
    }
    

    then to use it you do:

    void onButtonClicked() 
    {
        ParseXMLTask tsk = new ParseXMLTask();
        tsk.execute((Void)null);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to parse a XML file which I get from third party to
I need to parse a xml file which is practically an image of a
I have an XML file which I need to parse using PHP and send
I need to parse a XML file from the website.I have went through some
I have 2 questions: 1-I need to parse XML file and insert the data
I need to parse a large XML file (>1 GB) which is located on
I need to parse an XML file of coordinates and create a .png (from
I need to parse a fairly large XML file (varying between about a hundred
I need to parse a value from an xml and place it to image's
HI, i need a XML parser. i want to know that which one is

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.