I need to have a callback upon Work completion from WorkManager (android.arch.work:work-runtime-ktx:1.0.0-alpha11). Yet the listener I\'m adding is called immediately after work
The problem is not observed if you get the result with liveData like this, instead of using ListenableFuture
WorkManager.getInstance()
.getWorkInfoByIdLiveData(cloudSyncOneTimeWork.id)
.observe(yourLifecycle, yourObserver)
If you don't want to tie it to a lifecycleowner you can call it like this :
WorkManager.getInstance()
.getWorkInfoByIdLiveData(cloudSyncOneTimeWork.id)
.observeForever(yourObserver)
If you do so you are responsible to unregister the listener when you want