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

  • Home
  • SEARCH
  • 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 7951309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:31:19+00:00 2026-06-04T02:31:19+00:00

I’m using AsyncTask to update a horizontal Progress Dialog. There are no errors. The

  • 0

I’m using AsyncTask to update a horizontal Progress Dialog. There are no errors. The only thing I can’t figure out is that the ProgressDialog appears only after the background work.

That is, On clicking the button (which in turn does the following:)

    //within concerned OnClick Function of my main class:
    ASYNC_TEST GH=new ASYNC_TEST(this,"something","something","url", "booga");
    String response=GH.execute().get();

the button key remains pressed for a long time (HTTP POSTs are slow), and then suddenly the Progress Dialog appears for no more than a second, completing 100% in one swift go and disappears.

I’m pasting my code:

Below is the class extending AsyncTask which handles a HTTP Post operation and should be updating the progress bar.

    import android.app.ProgressDialog;
    import android.os.AsyncTask;
    import android.content.Context;
    import android.util.Log;

    public class ASYNC_TEST extends AsyncTask<Void, Integer, String> {

    private String result = "";
    private int ProgressStatus;
    String username, password, THE_URL, YouSure;

    private ProgressDialog pdb;

    public ASYNC_TEST(Context ConT, String username, String password,String THE_URL, String YouSure) 
    {
        Log.d("LOG_TAG", "Constructor");

        this.username = username;
        this.password = password;
        this.THE_URL = THE_URL;
        this.YouSure = YouSure;

        pdb = new ProgressDialog(ConT);
    }

    @Override
    protected void onPreExecute() 
    {

        pdb.setCancelable(true);
        pdb.setMessage("Logging In. Hold On a Sec...");
        pdb.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        pdb.setProgress(0);
        pdb.setMax(100);
        pdb.show();

        Log.d("LOG_TAG", "Pre-Execute");
        super.onPreExecute();
    }

    @Override
    protected void onPostExecute(String res) 
    {

        Log.d("LOG_TAG", "Post-Execute");
        pdb.dismiss();
        super.onPostExecute(res);
    }

    @Override
    protected void onProgressUpdate(Integer... progress) 
    {

        Log.d("LOG_TAG", "Progress Update: " + progress[0]);
        pdb.setProgress(progress[0]);
        super.onProgressUpdate();
    }

    @Override
    protected String doInBackground(Void... smt) 
    {
        Log.d("LOG_TAG", "doInBackground: ");

        try {

            ProgressStatus = 0;
            publishProgress(0);

            //Stuff

            ProgressStatus = 10;
            publishProgress(10);

            // More Stuff (HTTP POST)

            ProgressStatus = 20;
            publishProgress(10);

            //....Finally...

            ProgressStatus = 100;
            publishProgress(100);


        catch (Exception e) 
        {
            e.printStackTrace();
        }

        return "";

    }
    }

Log DATA:

    05-18 15:19:52.773: D/LOG_TAG(1596): Constructor
    05-18 15:19:52.822: D/LOG_TAG(1596): Pre-Execute
    05-18 15:19:52.832: D/LOG_TAG(1596): doInBackground: 
    05-18 15:19:53.482: D/dalvikvm(1596): GC freed 13648 objects / 583400 bytes in 77ms
    05-18 15:19:53.502: D/OpenSSLSessionImpl(1596): Freeing OpenSSL session
    05-18 15:19:53.982: D/dalvikvm(1596): GC freed 17495 objects / 885728 bytes in 77ms
    05-18 15:19:54.292: D/dalvikvm(1596): GC freed 10363 objects / 441600 bytes in 71ms
    05-18 15:19:54.982: D/dalvikvm(1596): GC freed 6564 objects / 298808 bytes in 71ms
    05-18 15:19:55.132: I/global(1596): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
    05-18 15:19:55.212: D/dalvikvm(1596): GC freed 843 objects / 85392 bytes in 65ms
    05-18 15:19:55.212: I/dalvikvm-heap(1596): Grow heap (frag case) to 4.120MB for 22148-byte allocation
    05-18 15:19:55.282: D/dalvikvm(1596): GC freed 1 objects / 14776 bytes in 68ms
    05-18 15:19:56.012: I/global(1596): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
    05-18 15:19:56.092: D/dalvikvm(1596): GC freed 1758 objects / 193224 bytes in 67ms
    05-18 15:19:56.172: D/dalvikvm(1596): GC freed 391 objects / 44792 bytes in 67ms
    05-18 15:19:56.252: D/dalvikvm(1596): GC freed 411 objects / 62120 bytes in 66ms
    05-18 15:19:56.252: I/dalvikvm-heap(1596): Grow heap (frag case) to 4.194MB for 54142-byte allocation
    05-18 15:19:56.322: D/dalvikvm(1596): GC freed 1 objects / 36104 bytes in 69ms
    05-18 15:19:56.413: D/dalvikvm(1596): GC freed 955 objects / 67536 bytes in 70ms
    05-18 15:19:56.413: I/dalvikvm-heap(1596): Grow heap (frag case) to 4.237MB for 81208-byte allocation
    05-18 15:19:56.483: D/dalvikvm(1596): GC freed 1 objects / 54152 bytes in 69ms
    05-18 15:19:56.852: I/global(1596): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
    05-18 15:19:56.942: D/dalvikvm(1596): GC freed 1317 objects / 241880 bytes in 71ms
    05-18 15:19:57.112: D/LOG_TAG(1596): Progress Update: 0
    05-18 15:19:57.112: D/LOG_TAG(1596): Progress Update: 10
    05-18 15:19:57.122: D/LOG_TAG(1596): Progress Update: 20
    05-18 15:19:57.122: D/LOG_TAG(1596): Progress Update: 30
    05-18 15:19:57.122: D/LOG_TAG(1596): Progress Update: 40
    05-18 15:19:57.133: D/LOG_TAG(1596): Progress Update: 50
    05-18 15:19:57.133: D/LOG_TAG(1596): Progress Update: 70
    05-18 15:19:57.133: D/LOG_TAG(1596): Progress Update: 90
    05-18 15:19:57.133: D/LOG_TAG(1596): Progress Update: 100
    05-18 15:19:57.133: D/LOG_TAG(1596): Post-Execute
    05-18 15:19:57.513: W/InputManagerService(51): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44c5f5a0
  • 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-04T02:31:21+00:00Added an answer on June 4, 2026 at 2:31 am

    Seems like the delay is due to get() method in String response=GH.execute().get();. It puts wait on the execution till the AsyncTask is completed.

    As per Javadoc:

    get(): Waits if necessary for the computation to complete, and then retrieves
    its result.

    I think you should simply call GH.execute(); to execute your AsyncTask wihtout affecting UI thread by putting it on hold.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... 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.