5

I am starting to implement the GcmNetworkManager to trigger a sync when the user gets their internet connection back

When looking at the docs for the OneoffTask it says that setExecutionWindow is mandatory

Mandatory setter for creating a one-off task

however I only want this to execute when the user has internet and it sounds like it could execute before the user has internet but in the window of windowStartDelaySeconds and windowEndDelaySeconds.

So does that mean that the network manager could execute the task sometime before windowEndDelaySeconds or does that mean that once internet has been restored it will execute in that time?

tyczj
  • 71,600
  • 54
  • 194
  • 296
  • The documentation for `setRequiredNetwork()` says "If the specified network is unavailable your task will not be executed until it becomes available." so I don't think it will execute. My question is will the task still execute if they don't get network until after `windowEndDelaySeconds`? You could always set that to a time far enough in the future where it won't matter but I'd still be interested in knowing as I expect it might not execute. – George Mulligan Apr 19 '16 at 19:42

1 Answers1

0

It means the CGM will try to execute at some point between the windowStartDelaySeconds and windowEndDelaySeconds after it has been registered, but also taking in consideration the specified network state.

For example, if you use .setExecutionWindow(30, 40) and use .setRequiredNetwork(Task.NETWORK_STATE_CONNECTED), that means the task will be executed at some point between 30 and 40 seconds after being registered only if you are connected to a network.

So yes, it could be executed before windowEndDelaySeconds, but it also depends on the network state.

sednanre
  • 478
  • 5
  • 16