title: Displaying progress in notification
body: <p>I am uploading a video to firebase and I want to show the status of the progress in both seekbar and in my notification. My seekbar behaves properly, but my notification with progress keeps showing download in progress status</p>
  
  <pre><code>@Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
       if (requestCode == RC_PHOTO_PICKER &amp;&amp; resultCode == RESULT_OK) {
          Uri selectedImageUri = data.getData();
  
          // Get a reference to store file at chat_photos/&lt;FILENAME&gt;
          StorageReference photoRef = mChatPhotosStorageReference.child(selectedImageUri.getLastPathSegment());
  
          // Upload file to Firebase Storage
          photoRef.putFile(selectedImageUri)
                  .addOnSuccessListener(this, new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;() {
                      public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                          // When the image has successfully uploaded, we get its download URL
                          //  progressBar.setVisibility(View.VISIBLE);
                          Uri downloadUrl = taskSnapshot.getDownloadUrl();
  
                          // Set the download URL to the message box, so that the user can send it to the database
                          Video video = new Video(downloadUrl.toString());
                          mMessagesDatabaseReference.push().setValue(video);
  
                      }
                  }).addOnProgressListener(new OnProgressListener&lt;UploadTask.TaskSnapshot&gt;() {
              @Override
              public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
                  final int progress = (int) ((100 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount());
  
                  seekBar.setProgress(progress);
                  final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
                          .setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary))
                          .setSmallIcon(R.mipmap.ic_launcher)
                          .setContentText("Download in progress")
                          .setAutoCancel(true);
  
                  if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.JELLY_BEAN) {
                      notificationBuilder.setPriority(Notification.PRIORITY_HIGH);
                  }
  
                  final NotificationManager notificationManager = (NotificationManager)
                          getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
  
                  new Thread(new Runnable() {
                      @Override
                      public void run() {
                          int incr;
                          // Do the "lengthy" operation 20 times
                          for (incr = progress; incr &lt;= 100; incr++) {
                              // Sets the progress indicator to a max value, the
                              // current completion percentage, and "determinate"
                              // state
                              notificationBuilder.setProgress(100, incr, false);
                              // Displays the progress bar for the first time.
                              notificationManager.notify(id, notificationBuilder.build());
                              // Sleeps the thread, simulating an operation
                              // that takes time
                              try {
                                  // Sleep for 5 seconds
                                  Thread.sleep(5*1000);
                              } catch (InterruptedException e) {
                                  Log.d(TAG, "sleep failure");
                              }
                          }
                          notificationBuilder.setContentText("Download complete")
                                  // Removes the progress bar
                                  .setProgress(0,0,false);
                          notificationManager.notify(id, notificationBuilder.build());
                        }
  
                      }
                  // Starts the thread by calling the run() method in its Runnable
                  ).start();
              }
          });
  
      }
  }
  </code></pre>
  
  <p>Seekbar works fine, but notification with progress sometimes shows download complete even though file is not uploaded to firebase and after showing download complete, it agains shows the notification of in progress.What am i doing wrong? Please help. I already refer the following documentation &amp; followed the steps but not able to figure it out why my notification with progress is behaving this way
  <a href="https://developer.android.com/training/notify-user/display-progress.html" rel="nofollow noreferrer">https://developer.android.com/training/notify-user/display-progress.html</a></p>