Android WorkManager api for running daily task in Background

前端 未结 6 574
野的像风
野的像风 2020-12-09 04:16

I need to call one API daily in the background even if the app is closed. I have seen about WorkManager API. For my scenario, I tried PeriodicWorkRequest but unfortunately,

6条回答
  •  余生分开走
    2020-12-09 04:26

    If you add a tag to the PeriodicWorkRequestBuilder, and then call WorkManager.getInstance().cancelAllWorkByTag(REQUEST_TAG) before you enqueue the periodic request, that will keep the dupes from happening:

    Android Workmanager PeriodicWorkRequest is not unique

提交回复
热议问题