androidperiodic-taskgcmtaskservice

GCMTaskManager PeriodicTask... restart timer and/or see how much time is left?


I am trying to use the GCMTaskManager to schedule a periodic task that runs approximately every 30 minutes. When it runs, it does an "update" on some internal data in the APP.

I have this preliminarily running and can see, using a LOG command in the OnRunTask, that the task fires as desired.I have it operating (at least according to a LOG I am populating when the OnRunTask fires.

I have two issues I can't determine if it can be done....

Thanks

Pete


Solution

  • For 1) GCMNetworkManager does not provide an interface for keeping track of the time elapsed/remaining but you can do so yourself by maintaining a variable storing the last updated timestamp for your data.

    2) From the docs

    When Google Play Services or the client app is updated, all scheduled tasks are removed. GcmNetworkManager invokes the client app’s onInitializeTasks(). Override this function to reschedule necessary tasks.