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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:32:30+00:00 2026-06-01T12:32:30+00:00

As I created a Progress bar using below code in a on click method

  • 0

As I created a Progress bar using below code in a on click method of button. but after clicking button it takes 2-3 seconds to display progress bar.how to reduce that delay to start progress bar.

 public void getProgressBar() {

    progressBar = new ProgressDialog(this);
    progressBar.setCancelable(true);
    progressBar.setMessage("Loading...");
    progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressBar.show();
    progressBarStatus = 0;

    new Thread(new Runnable() {
        public void run() {
            while (progressBarStatus < 100) {

                progressBarStatus = doSomeTasks();////I am loading service 
                progressBarHandler.post(new Runnable() {
                    public void run() {
                        progressBar.setProgress(progressBarStatus);
                    }
                });
            }

                if (progressBarStatus >= 100 ) {

                    progressBar.dismiss();
                    startActivity(new Intent(getApplicationContext(),
                            StatisticDisplay.class));

            }
        }
    }).start();
}
  • 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-01T12:32:32+00:00Added an answer on June 1, 2026 at 12:32 pm
     public class BackgroundAsyncTask extends AsyncTask<Void, Integer, Void> {
    
      int myProgress;
    
      @Override
      protected void onPostExecute(Void result) {
       // TODO Auto-generated method stub
      }
    
      @Override
      protected void onPreExecute() {
       // TODO Auto-generated method stub
       myProgress = 0;
      }
    
      @Override
      protected Void doInBackground(Void... params) {
       // TODO Auto-generated method stub
       while(myProgress<100){
        myProgress++;
        publishProgress(myProgress);
           SystemClock.sleep(100);
       }
       return null;
      }
    
      @Override
      protected void onProgressUpdate(Integer... values) {
       // TODO Auto-generated method stub
       progressBar.setProgress(values[0]);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a website loading progress bar using Jquery UI Progress bar. This
I'm downloading some pictures and have created a progress bar. I'm using asynchronous mode
I'm trying to code a progress bar...i'm using the youtube api to create custom
I have created a C# COM DLL which is essentially an enhanced progress bar
I am trying to create a download progress bar in python using the urllib2
i need to download large pdf from web and i created a progress bar
I am using css to create a gantt-chart style progress bar. It consists of
I am using the progress bar for the web view.I need to stop progress
I'm currently loading a webpage using a thread and I need a progress bar
I wrote the below method to archive files into one file using binary mode:

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.