Reputation: 1395
I am using android.arch.work:work-runtime-ktx:1.0.0-alpha11 and have bumped into an issue on Samsung Galaxy S8+ running Android 7.0. With other devices it works fine.
val constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
val inputData: Data = Data.Builder()
.putString(INPUT_DATA_FRONT_URI, front?.toString())
.putString(INPUT_DATA_BACK_URI, back?.toString())
.build()
val work = OneTimeWorkRequestBuilder<LicenseUploadWorker>()
.setConstraints(constraints)
.setInputData(inputData)
.build()
workManager.beginUniqueWork(LICENSE_UPLOAD_WORKER, ExistingWorkPolicy.REPLACE, work)
.enqueue()
Work is scheduled and executed successfully, however the LiveData i get from here
workManager.getWorkInfoByIdLiveData(work.id)
never gets the WorkInfo.State.SUCCEEDED
state update. From the logs I can see that the work completes without any issues:
11-26 12:12:03.693 6820 6852 I WorkerWrapper: Worker result SUCCESS for Work
Is there a way around this issue for now?
Upvotes: 4
Views: 528
Reputation: 565
I had the same issue during the development cycle of my app (on a different device). The solution for me was to simply uninstall my app. The next time I launched it from Android Studio everything worked.
Upvotes: 0
Reputation: 5770
you can observe the status by subscribing directly to the return value of enqueue()
, e.g.:
val workOperation = workManager.beginUniqueWork(LICENSE_UPLOAD_WORKER, ExistingWorkPolicy.REPLACE, work).enqueue()
workOperation.state.observe(this, Observer { state ->
Timber.d("state: $state")
})
Upvotes: 1