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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:07:51+00:00 2026-05-30T19:07:51+00:00

I have learn how to get progressbar works with perticular task from here .

  • 0

I have learn how to get progressbar works with perticular task from here.

But i am using chronometer in my app. And based on that value i want to set the ProgressBar.

So how to do it. ?

I have made this thread to work.
Code:

// Start lengthy operation in a background thread         
    progressThread = new Thread(new Runnable() {             
        public void run() {                 
            while (mProgressStatus < 100) {                     
                mProgressStatus = doWork();                     
                // Update the progress bar                     
                mHandler.post(new Runnable() {                         
                    public void run() {                             
                        progressBar.setProgress(mProgressStatus);                         
                    }                     
                });                 
            }             
        }         
    });

    progressThread.start();

I know that i have to make task that continous return the int data to the progressStatus. But how to do it with chronometer that i dont know. So please help me for that.

Thanks.

  • 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-30T19:07:52+00:00Added an answer on May 30, 2026 at 7:07 pm

    Your problem seem to be your doWork() method (as you mentioned in comment that there is nothing done in that method). As you can see progress of the progressBar depends from this method:

    mProgressStatus = doWork();
    

    Lets suppose that your cronometer is updating every second, so the progressBar will be full when 100 seconds will pass. To achive that, your doWork method should return increasing value of seconds passed, i.e 1,2,3…to 100. But returning that value only is not enough, because with your current code the progressBar will be filled instantly.
    The most simple solution would be:

    mProgressStatus = 0;
    progressThread = new Thread(new Runnable() {             
        public void run() {                 
            while (mProgressStatus < 100) {                                          
                // Update the progress bar                     
                mHandler.post(new Runnable() {                         
                    public void run() {                             
                        progressBar.setProgress(mProgressStatus);                         
                    }                     
                });
                mProgressStatus ++;
                android.os.SystemClock.sleep(1000); // Thread.sleep() doesn't guarantee 1000 msec sleep, it can be interrupted before               
            }             
        }         
    });
    
    progressThread.start();
    

    Hope this helps,
    Serhiy.

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

Sidebar

Related Questions

Below I have written a sample program that I have written to learn about
I've recently decided that I just have to finally learn C/C++, and there is
I am programming in Ruby and have wanted to learn about matrices but I
I have a JavaScript-based timeline which needs to use data from an SQL server.
I have been trying to learn and get used to version control, more specifically
Do I really have to learn Objective-C to develop solid Mac Apps? As Mac
One day I suspect I'll have to learn hadoop and transfer all this data
Other than the Java language itself, you have to learn the java framework. Similiar
I have started to learn about python and is currently reading through a script
I have started to learn ANTLR and have both the 2007 book The Definitive

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.