I am using ListenableWorker to perform background tasks. Also I want OS to be aware of my service importance, so I call
setForegroundAsync(new ForegroundInfo(WorkerConstants.NOTIFICATION_FOREGROUND_ID,
builder.build()));
As suggested in the google documentation.
But when my service stopped or cancelled, i can still see foreground service notification and i cannot remove it.
Furthermore, I added cancel button to this notification, but it does nothing, I cannot close it:
PendingIntent intent = WorkManager.getInstance(getApplicationContext())
.createCancelPendingIntent(getId());
builder.addAction(R.drawable.ic_redesign_exit,"Stop",intent);
Any suggestions?