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....
Is there a way to see how much time is "left" before the next OnRunTask
fires... or... approximately what "time" it should run next? Example, if there is 30 minutes for the PeriodTask... and 18 minutes have lapsed, can we programmatically see that 12 minutes remain?
I have an internal "button" to manual fire the APPS update. If the user hits this, I want to "restart" the PeriodicTask timer from that point. That is, if the 30 minute OnRunTask
is suppose to fire in approximately 12 minutes, and the user hits the UPDATE manually, I want the OnRunTask
to now restart from for 30 minutes from the button press. Can this be done?
Thanks
Pete
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.