In my android app, I have a requirement where I need to execute a task at 5 days interval. The task is to call an API and get the data from the server even if the app is not running/terminated.
I have checked the potential options to do this which are as below:
Alarm manager + Broadcast receiver + Intentservice
- In this approach the problem is with the restrictions imposed by the Android framework for the intentService. Also, the registered Alarm will be erased if the device is rebooted.WorkManager
- this seems a better approach for my task to have a guaranteed execution on the latest android versions but still it's not clear whether to usePeriodicWorkRequest
orOneTimeWorkRequest
and keep rescheduling it.
Please note that it's not critical to execute this task on an exact clock time but it should work after each 5 days of interval.