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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:09:19+00:00 2026-06-08T09:09:19+00:00

I’ve got a file download application which I need to update progress using Asnc

  • 0

I’ve got a file download application which I need to update progress using Asnc Task method
The progress will be displayed by Dialog and Notification Bar simultaneously, just like the sample in the Google PLay

When I run the method , Notification Bar shows extremely slow response.
IN the ONProgressUpdate, I only update two UI progress without synchornization.

When I use thread sleep to slow down the process, it runs smoothly but the download speed is very low.

How can we ensure two UI threads running smoothly while maintaining acceptably fast downloading speed?

this is the Code

Please answer 🙂

@Override
protected void onProgressUpdate(Integer... values) {
    if (values.length>0) {
        //Log.d("Download Activity", "progressUpdate:"+values[0]);
        if (values[0] < 0) {
            this.cancel(true);
            showNetworkErrorDialog();
        } else {
            //size += values[0];
            //Log.d("Download Activity", "download size:"+size);
            //downloadedGoodListSize += values[0];
            //downloadProgressBar.incrementProgressBy(values[0]);
            setCurrentProgress(values[0]);
            downloadProgressBar.setProgress(values[0]);
            double currentProg = downloadProgressBar.getProgress()*1.0/downloadProgressBar.getMax()*100;
            //progressTextView.setText( decimalFormat.format(downloadedGoodListSize*1.0/downloadProgressBar.getMax()*100.0)+"%");
            progressTextView.setText(decimalFormat.format(downloadProgressBar.getProgress()*1.0/downloadProgressBar.getMax()*100)+"%");


            notification.contentView.setProgressBar(R.id.pb, 100, (int)currentProg, false);

            nm.notify(notificationID, notification);

        }
    }
}

@Override
protected void onPostExecute(Boolean result) {
    Log.i("Download Activity", "onPostExecute: starting");
    downloadProgressBar.setProgress(downloadProgressBar.getMax());
    progressTextView.setText(100+"%");
    wheelProgressBar.setVisibility(View.GONE);
    downloadingTextView.setText(getFinishedText());

   notification.contentView.setProgressBar(R.id.pb, 100, 100, false);
   nm.notify(notificationID, notification);
   nm.cancelAll();

    Log.i("Download Activity", "onPostExecute: set interface ok");
    finishDialog.show();

}
  • 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-08T09:09:21+00:00Added an answer on June 8, 2026 at 9:09 am

    The below is my code

    @Override
        protected void onProgressUpdate(Integer... values) {
            if (values.length>0) {
                //Log.d("Download Activity", "progressUpdate:"+values[0]);
                if (values[0] < 0) {
                    this.cancel(true);
                    showNetworkErrorDialog();
                } else {
                    //size += values[0];
                    //Log.d("Download Activity", "download size:"+size);
                    //downloadedGoodListSize += values[0];
                    //downloadProgressBar.incrementProgressBy(values[0]);
                    setCurrentProgress(values[0]);
                    downloadProgressBar.setProgress(values[0]);
                    double currentProg = downloadProgressBar.getProgress()*1.0/downloadProgressBar.getMax()*100;
                    //progressTextView.setText( decimalFormat.format(downloadedGoodListSize*1.0/downloadProgressBar.getMax()*100.0)+"%");
                    progressTextView.setText(decimalFormat.format(downloadProgressBar.getProgress()*1.0/downloadProgressBar.getMax()*100)+"%");
    
    
                    notification.contentView.setProgressBar(R.id.pb, 100, (int)currentProg, false);
    
                    nm.notify(notificationID, notification);
    
                }
            }
        }
    
    @Override
        protected void onPostExecute(Boolean result) {
            Log.i("Download Activity", "onPostExecute: starting");
            downloadProgressBar.setProgress(downloadProgressBar.getMax());
            progressTextView.setText(100+"%");
            wheelProgressBar.setVisibility(View.GONE);
            downloadingTextView.setText(getFinishedText());
    
           notification.contentView.setProgressBar(R.id.pb, 100, 100, false);
           nm.notify(notificationID, notification);
           nm.cancelAll();
    
            Log.i("Download Activity", "onPostExecute: set interface ok");
            finishDialog.show();
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.