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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:01:58+00:00 2026-06-14T01:01:58+00:00

I have an AsyncTask to handle a reasonably long running update process, and I

  • 0

I have an AsyncTask to handle a reasonably long running update process, and I want a progress dialog that shows, in order:

  1. “Starting update” (for a brief second)
  2. “Downloading update” (no progress bar — I don’t know how big the update will be before I download it)
  3. “Saving update data” (with a 0-100% progress bar)
  4. “Saving update images” (with a 0-100% progress bar)
  5. “Update finished” (for a brief second before the dialog disappears)

I’m having problems toggling the progress dialog between determinate (progress bar shows up) and indeterminate (no progress bar).

The code in my AsyncTask follows:

private final ProgressDialog progressDialog;

public SynchronizeTask(Activity activity)
{
    progressDialog = new ProgressDialog(activity);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
}

protected void onPreExecute() {
    progressDialog.setMessage("Starting update...");
    progressDialog.setCancelable(false);
    progressDialog.show();
}

...lots of code here...

// all of these are set from doInBackground()
private String progressMsg;
private int progressTotal;
private int progressProgress;

protected void onProgressUpdate(Void... values) {
    progressDialog.setMessage(progressMsg);
    if (progressTotal > 0) {
        progressDialog.setIndeterminate(false);
        progressDialog.setMax(progressTotal);
        progressDialog.setProgress(progressProgress);
    } else {
        progressDialog.setIndeterminate(true);
        progressDialog.setMax(0);
        progressDialog.setProgress(0);
    }
}

I tried toggling determinate with setIndeterminate() — the problem here is that the progress dialog shows “NaN” and “0%” at the bottom of the dialog even though there’s no “bar” left in indeterminate mode.

Then I tried using setProgressNumberFormat() and setProgressPercentFormat() just to hide the numbers — but neither of these are supported in Android below 3.0.

Then I tried using setProgressStyle() to toggle between STYLE_SPINNER and STYLE_HORIZONTAL — calling setProgressStyle() in my onProgressUpdate() seems to cause my app to crash.

Is there any easy way to toggle a progress dialog between determinate and indeterminate mode?

  • 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-14T01:02:00+00:00Added an answer on June 14, 2026 at 1:02 am

    Might be a good idea to close one progress dialog and open another, with different style.

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

Sidebar

Related Questions

I have an AsyncTask and on the background I want to start Service that
I have a long running Async Task that sends some data to my server
I have an AsyncTask that handles a rather long download, using HttpClient. I'd like
My goal is to have an AsyncTask that can execute multiple times (one task
I have a class that extends AsyncTask , which fetches the gps cordinates from
I have AsyncTask that processes some background HTTP stuff. AsyncTask runs on schedule (Alarms/service)
I have an AsyncTask that fetches some data and then updates the UI with
I have a standard AsyncTask like this: // starting AsyncTask in onCreate new TaskName().execute();
I have a slider that can be pulled up and then it shows a
I have an Asynctask set up to pull icy metadata from shoutcast streams that

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.