How does WorkManager schedule GET requests to REST API?

前端 未结 2 1609
梦如初夏
梦如初夏 2021-02-07 08:22

I\'ve had a look at the codelab for WorkManager plus some examples on here, but everything in code I have seen is either related to doing work locally on the device or work uplo

2条回答
  •  情深已故
    2021-02-07 08:34

    This is initial thought. Somebody please correct me if i'm wrong.

    my worker would already have posted that it was successful and it probably would not proceed with the callback, right?

    we can use the callback from API reponse, to construct output Data of the worker and set it using worker.setOutputData() Then listen to the LiveData from workManager. From this workstatus we can get outputData using, workStatus.getOutputdata(). This data can give us the API response we want.

    We can pass this response to next worker in the worker chain to carry out tasks like updating local DB.

提交回复
热议问题