GcmNetworkManager OneoffTask ExecutionWindow necessary?

I am starting to implement GcmNetworkManager to start synchronization when a user gets their internet connection back

When viewing documents for OneoffTask, it says setExecutionWindow is required

Mandatory set for creating a one-time task

however, I only want this to be executed when the user has the Internet, and it looks like it can be executed before the user has Internet access, but in the window windowStartDelaySeconds and windowEndDelaySeconds .

Does this mean that the network manager could complete the task earlier than windowEndDelaySeconds , or does it mean that after the restoration of the Internet it will be executed at this time?

+5
source share
1 answer

This means that CGM will try to execute at some point between windowStartDelaySeconds and windowEndDelaySeconds after registering it, but also take into account the indicated network status.

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

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

0
source

Source: https://habr.com/ru/post/1247467/


All Articles