title: Firebase Storage: Showing Progress of File Upload
body: <p>Just wanted to improve the File Upload of Firebase Storage with a progress dialog. </p>
  
  <pre><code>.addOnProgressListener(new OnProgressListener&lt;UploadTask.TaskSnapshot&gt;() {
          @Override
          public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
              double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
              progressDialog.setMessage((int) progress + "");
          }
      });
  </code></pre>
  
  <p>But the getBytesTransferred() and getTotalByteCount methods of TaskSnapshot does not allow to be called here. Android Studio says: This method should be only accessed from a test or within private scope.
  The <a href="https://firebase.google.com/docs/reference/android/com/google/firebase/storage/UploadTask.TaskSnapshot.html#getBytesTransferred()" rel="nofollow noreferrer">docs</a> does not say that there are any problems and it seemed that this is the regular way to show the progress (
  <a href="https://stackoverflow.com/questions/38278249/update-progress-bar-with-firebase-uploading">update progress bar with Firebase uploading</a> )</p>
  
  <p>So why the methods don't want to be called?</p>
  
  <p>Edit: Works with <code>@SuppressWarnings("VisibleForTests")</code></p>