java.lang.Object | ||
↳ | com.google.android.gms.gcm.Task.Builder | |
↳ | com.google.android.gms.gcm.PeriodicTask.Builder |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Optional setter for specifying any extra parameters necessary for the task.
| |||||||||||
Optional setter for specifying how close to the end of the period set in
setPeriod(long) you are willing to execute. | |||||||||||
Mandatory setter for creating a periodic task.
| |||||||||||
Optional setter to specify whether this task should be persisted across reboots.
| |||||||||||
Set the network state your task requires to run.
| |||||||||||
Set whether your task requires that the device be connected to power in order to
execute.
| |||||||||||
Set whichever
GcmTaskService you implement to execute the logic for this task. | |||||||||||
Mandatory setter for specifying the tag identifier for this task.
| |||||||||||
Optional setter to specify whether this task should override any preexisting tasks
with the same tag.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Optional setter for specifying any extra parameters necessary for the task.
Parameters | |
---|---|
extras |
Bundle
|
Returns | |
---|---|
PeriodicTask.Builder |
Optional setter for specifying how close to the end of the period set in
setPeriod(long)
you are willing to execute.
For example, specifying a period of 30 seconds, with a flex value of 10 seconds
will allow the scheduler to determine the best moment between the 20th and 30th
second at which to execute your task.
Parameters | |
---|---|
flexInSeconds |
long
|
Returns | |
---|---|
PeriodicTask.Builder |
Mandatory setter for creating a periodic task. This specifies that you would like
this task to recur at most once every mIntervalInSeconds.
By default you have no control over where within this period the task will execute.
If you want to restrict the task to run within a certain timeframe from the end of
the period, use setFlex(long)
Parameters | |
---|---|
periodInSeconds |
long
|
Returns | |
---|---|
PeriodicTask.Builder |
Optional setter to specify whether this task should be persisted across reboots. Defaults to true. Callers must hold the permission android.Manifest.permission.RECEIVE_BOOT_COMPLETED, otherwise this setting is ignored.
Parameters | |
---|---|
isPersisted |
boolean :
True if this task should be persisted across device reboots.
|
Returns | |
---|---|
PeriodicTask.Builder |
Set the network state your task requires to run. If the specified network is
unavailable your task will not be executed until it becomes available.
The default for either a periodic or one-off task is
NETWORK_STATE_CONNECTED
. Note that changing this to
NETWORK_STATE_ANY
means there is no guarantee that data will be available
when your task executes.
In addition, the only guarantee for connectivity is at the moment of execution - it is
possible for the device to lose data shortly after your task begins executing.
Parameters | |
---|---|
requiredNetworkState |
int
|
Returns | |
---|---|
PeriodicTask.Builder |
Set whether your task requires that the device be connected to power in order to execute. Use this to defer nonessential operations whenever possible. Note that if you set this field and the device is not connected to power your task will not run until the device is plugged in. One way to deal with your task not executing until the constraint is met is to schedule another task without the constraints that is subject to some deadline that you can abide. This task would be responsible for executing your fallback logic.
Parameters | |
---|---|
requiresCharging |
boolean
|
Returns | |
---|---|
PeriodicTask.Builder |
Set whichever GcmTaskService
you implement to execute the logic for this task.
Parameters | |
---|---|
gcmTaskService |
Class :
Endpoint against which you're scheduling this task.
|
Returns | |
---|---|
PeriodicTask.Builder |
Mandatory setter for specifying the tag identifier for this task. This tag will be
returned at execution time to your endpoint. See
onRunTask(com.google.android.gms.gcm.TaskParams)
Maximum tag length is 100.
Parameters | |
---|---|
tag |
String :
String identifier for this task. Consecutive schedule calls for the same
tag will update any preexisting task with the same tag.
|
Returns | |
---|---|
PeriodicTask.Builder |
Optional setter to specify whether this task should override any preexisting tasks with the same tag. This defaults to false, which means that a new task will not override an existing one.
Parameters | |
---|---|
updateCurrent |
boolean :
True to update the current task with the parameters of the new.
Default false.
|
Returns | |
---|---|
PeriodicTask.Builder |