Progressidialog does not quit 0%

Asked

Viewed 90 times

0

I am uploading an image to the firebase database and I want to show it in the file but it always stays 0/100.

 progress=new ProgressDialog(getContext());
    progress.setMessage("Downloading Music");
    progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progress.setIndeterminate(true);



   progress.show();
    uploadTask.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
        @Override
        public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
            double p = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
          int currentprogress = (int) p;
            progress.setProgress(currentprogress);

            if(currentprogress==100){
                progress.dismiss();
            }
        }
    });
  • The variable that is receiving the progress update is the variable "p" and not "currentprogress", so instead of doing this Progress.setProgress(currentprogress); do Progress.setProgress((int) p);

  • i forgot to put that part,int currentprogress = (int) p;

1 answer

0

The Progress.setIndeterminate(true); makes it not measure progress. Changes to false that must resolve.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.