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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:20:09+00:00 2026-06-05T07:20:09+00:00

I use asynctask to get data from web services. But progessdialog not show when

  • 0

I use asynctask to get data from web services. But progessdialog not show when thread execute

private class Task_Bank extends AsyncTask<Void, Void, ArrayList<String>>{
        @Override
        protected ArrayList<String> doInBackground(Void... params) {
            ArrayList<String> arrayBankL = new ArrayList<String>();
            String url="http://qhoang.org/webservices/get_list_bank.php";
            JSONParser jsonParser = new JSONParser();
            JSONObject jsonObject = jsonParser.getJSONFromURL(url);
            int i = 0;
            try{
                JSONArray array_bank = jsonObject.getJSONArray("list_bank");
                for(i=0;i<array_bank.length();i++){
                    JSONObject node = array_bank.getJSONObject(i);
                    JSONObject c = node.getJSONObject("node_list_bank");
                    String namebank = c.getString("tennganhang");
                    arrayBankL.add(namebank);
                }
            }catch(JSONException e){
                e.printStackTrace();
            }
            return arrayBankL;
        }

        @Override
        protected void onPostExecute(ArrayList<String> result) {
            ArrayAdapter<String> arrayAdapter_bank = new ArrayAdapter<String>(TaskAActivity.this,android.R.layout.simple_spinner_item,result);
            arrayAdapter_bank.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spn_bank.setAdapter(arrayAdapter_bank);
        }

        @Override
        protected void onProgressUpdate(Void... values) {
            ProgressDialog MyDialog = ProgressDialog.show( TaskAActivity.this, " " , " Loading. Please wait ... ", true);
        }   
}

OnCreate()

Task_Bank a = new Task_Bank();
a.execute();

JSONParser is class i code to use parser JSON from webservices result.

  • 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-06-05T07:20:10+00:00Added an answer on June 5, 2026 at 7:20 am

    You should show() dialog in onPreExecute() that starts before task starting and is right place for this. in onProgressUpdate you should only increment progress for your ProgressDialog. and when task finished so in onPostExecute() call MyDialog.dismiss()

    @Override
    protected void onPreExecute() {
       progressDialog.show();           
    }
    

    It could be like this

    ProgressDialog MyDialog = ProgressDialog.show(TaskAActivity.this, " " , " Loading. Please wait ... ", true);
    // some settings
    Task_Bank a = new Task_Bank();
    a.execute();
    
    @Override
       protected void onPreExecute() {
          MyDialog.show();          
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: I need a good way to get data from a thread to
I wanted to use AsyncTask to load images to the ListView. private class LoadImageTask
In order to get XML data from a server repeatedly, I'm attempting to use
In my application I use AsyncTask in oncreate . Sometimes I get Launch timeout
I want to lock back button while my data process. I use AsyncTask to
Is it at all possible, from within an AsyncTask that is NOT an inner
I have a backgorund thread that extends AsyncTask and which I use in activity
I have an Activity that retrieves data from a web service. This data is
I'm reading some GPS data (longitude,latitude) from a ServerManager class that stores it. The
I'm using a background thread to read from a Sqlite database some GPS data...and

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.