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 Answer 1

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.

2
  • so how to solve it? Sep 26, 2021 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 but i'm not sure it will works because i never used it.
    – Karol
    Sep 27, 2021 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.