title: ListenableWorker done, but ongoing foreground notification still exists?
body: <p>I am trying to use ListenableWorker to perform some background API calls.</p>
  
  <p>During this process I want to display notification with a progress.</p>
  
  <p>I use <strong>setForegroundAsync()</strong>  function as per this documentation <a href="https://developer.android.com/topic/libraries/architecture/workmanager/advanced/long-running" rel="nofollow noreferrer">google docs</a></p>
  
  <p><strong>The problem is when my ListenableWorker stops, i can still see my ongong notification and i cant remove it.</strong></p>
  
  <p>This is my refresh fucntion where I change notification parameters:</p>
  
  <pre><code>private void updateRefreshStatus(float objectsProcessed, int totalObjects) {
          if (totalObjects == 0) {
              setProgressAsync(new Data.Builder().putFloat(PROGRESS_CONSTANT_ID, 100.0f).build());
              setForegroundAsync(createForegroundInfo(FloatFormatter.roundFloatTwoDigitsAsString(100f)));
          } else {
              setProgressAsync(new Data.Builder().putFloat(PROGRESS_CONSTANT_ID, (objectsProcessed / (float) totalObjects) * 100f).build());
              setForegroundAsync(createForegroundInfo(FloatFormatter.roundFloatTwoDigitsAsString((objectsProcessed / (float) totalObjects) * 100f)));
          }       
      }
  </code></pre>
  
  <p>This is how I create my foregroundInfo:</p>
  
  <pre><code>private ForegroundInfo createForegroundInfo(@NonNull String progress) {
          Notification notification = WorkerUtils.prepareProgressNotification("Update",
                  "Update progress " + progress + " %",
                  getApplicationContext());
          return new ForegroundInfo(NOTIFICATION_PROGRESS_ID,notification);
      }
  </code></pre>
  
  <p>This is my progress notification code:</p>
  
  <pre><code>static Notification prepareProgressNotification(String title, String message, Context context) {
          // Make a channel if necessary
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) {
              // Create the NotificationChannel, but only on API 26+ because
              // the NotificationChannel class is new and not in the support library
              CharSequence name = WorkerConstants.VERBOSE_NOTIFICATION_CHANNEL_NAME;
              String description = WorkerConstants.VERBOSE_NOTIFICATION_CHANNEL_DESCRIPTION;
              int importance = NotificationManager.IMPORTANCE_HIGH;
              NotificationChannel channel =
                      new NotificationChannel(WorkerConstants.CHANNEL_ID, name, importance);
              channel.setDescription(description);
  
              // Add the channel
              NotificationManager notificationManager =
                      (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
  
              if (notificationManager != null) {
                  notificationManager.createNotificationChannel(channel);
              }
          }
  
          // Create the notification
          NotificationCompat.Builder builder = new NotificationCompat.Builder(context, WorkerConstants.CHANNEL_ID)
                  .setContentTitle(title)
                  .setSmallIcon(R.drawable.ic_launcher)
                  .setContentText(message)
                  .setTicker(title)
                  .setOngoing(true)
                  .setAutoCancel(true)
                  .setPriority(NotificationCompat.PRIORITY_HIGH)
                  .setVibrate(new long[0]);
  
          // Show the notification
          return builder.build();
      }
  </code></pre>
  
  <p>I tried calling cancelAll, cancel(id), but it does nothing in my case.</p>
  
  <p><strong>UPDATE:</strong> Removing .setOngoing(true) from builder, does nothing for me its seems like setForegroundAsync() issue?</p>