0

I built an app that downloads from URL, but when it starts ProgressDialog. It starts counting like 1...23...45...76...93..100 instead of 1..2..3..4..5...6 How to make it count from 1 to 100 ?

ParseAdapter.java

 progressDialog.show();
                mProgressDialog1 = new ProgressDialog(context);
                mProgressDialog1.setMessage("Please wait few seconds!");
                mProgressDialog1.setTitle("Downloading...");
                mProgressDialog1.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                mProgressDialog1.setMax(100);
                mProgressDialog1.setCancelable(false);

    final float downloadProgress = downloadedBytes * 100f / totalBytes;
                                if (downloadProgress > 99.9) // stop repeating timer (it's also useful for error prevention)
                                    progressTimer.cancel();


                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        mProgressDialog1.setProgress((int) downloadProgress);
                                    }


                                });

1 Answers1

0

It is probably caused because of internet traffic. if file is small, one packet takes more than 1 percent of file so you see unsmooth progress.

Karol
  • 66
  • 1
  • 6
  • so how to solve it? – Jimmy Guetta Sep 26 '21 at 23:36
  • I mean it is quite natural. If you are downloading file, speed may change so progress is not changing linear. And progress is changing by for about 20% because this amount of data is downloaded at one moment. You can checkout this library [smoothprogressbar](https://github.com/castorflex/smoothprogressbar) but i'm not sure it will works because i never used it. – Karol Sep 27 '21 at 07:33