Fixed
Status Update
Comments
ra...@google.com <ra...@google.com> #2
Is there any way to use this while it's not available, without a big if else where we do everything duplicated? Like this example.
val notification = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
Notification.Builder(...)
.setContentTitle("Title")
.setStyle(...)
// Duplicate everything here!!!
.build()
} else {
NotificationCompat.Builder(...)
.setContentTitle("Title")
.setStyle(...)
// Duplicate everything here!!!
.build()
}
Description
Devices/Android versions reproduced on: Google Pixel, P DP4
As presently implemented, setAllConstraintsMet() needs to be called *after* the work is enqueued in WorkManager. If you call setAllConstraintsMet() before the call to enqueue(), the subsequent enqueue() call returns immediately without actually executing the work.
Ideally, the order of events here should not matter -- we should be able to call setAllConstraintsMet() before or after enqueuing the work, particularly when using the SynchronousExecutor. However, if there are technical reasons why the work needs to be enqueued first before setAllConstraintsMet() is called, the documentation should be much plainer about that order-of-execution requirement.
Thanks!