I need to schedule a task that runs every 24 hours to get small data from a remote server. GcmNetworkManager seems to be a prefect candidate since I need to support sdk 15+. (JobScheduler - only 21+).
How I achieve this by expanding the application. onCreate , I create a PeriodicTask with a specific tag, and I call .setUpdateCurrent (false) (So, the 1st of them gets scheduled and subsequent tasks should be ignored, since they should not update existing tasks).
I read in the documentation
Important. When the Google Play Services or client application is updated, all scheduled tasks will be deleted. GcmNetworkManager calls client applications onInitializeTasks (). Override this function to transfer the necessary tasks.
In my scenario, this does not matter, since onCreate of Application I always create an update task. Is there a better way than I do? (I would also like to check if there is a pending periodic task with a given tag)
source
share