Summary: Inherited Fields | Ctors | Methods | Protected Methods | Inherited Methods | [Expand All]
public static class

# OneoffTask.Builder

extends Task.Builder

java.lang.Object
↳ | com.google.android.gms.gcm.Task.Builder
| ↳ | com.google.android.gms.gcm.OneoffTask.Builder

## Summary

[Expand] Inherited Fields
From class com.google.android.gms.gcm.Task.Builder
protected Bundle | extras |
protected String | gcmTaskService |
protected boolean | isPersisted |
protected int | requiredNetworkState |
protected boolean | requiresCharging |
protected String | tag |
protected boolean | updateCurrent |

Public Constructors
| OneoffTask.Builder()

Public Methods
OneoffTask | build()
OneoffTask.Builder | setExecutionWindow(long windowStartDelaySeconds, long windowEndDelaySeconds) Mandatory setter for creating a one-off task.
OneoffTask.Builder | setExtras(Bundle extras) Optional setter for specifying any extra parameters necessary for the task.
OneoffTask.Builder | setPersisted(boolean isPersisted) Optional setter to specify whether this task should be persisted across reboots.
OneoffTask.Builder | setRequiredNetwork(int requiredNetworkState) Set the network state your task requires to run.
OneoffTask.Builder | setRequiresCharging(boolean requiresCharging) Set whether your task requires that the device be connected to power in order to execute.
OneoffTask.Builder | setService(Class<? extends GcmTaskService> gcmTaskService) Set whichever `GcmTaskService` you implement to execute the logic for this task.
OneoffTask.Builder | setTag(String tag) Mandatory setter for specifying the tag identifier for this task.
OneoffTask.Builder | setUpdateCurrent(boolean updateCurrent) Optional setter to specify whether this task should override any preexisting tasks with the same tag.

Protected Methods
void | checkConditions()

[Expand] Inherited Methods
From class com.google.android.gms.gcm.Task.Builder
abstract Task | build()
void | checkConditions()
abstract Task.Builder | setExtras(Bundle extras) Optional setter for specifying any extra parameters necessary for the task.
abstract Task.Builder | setPersisted(boolean isPersisted) Optional setter to specify whether this task should be persisted across reboots.
abstract Task.Builder | setRequiredNetwork(int requiredNetworkState) Set the network state your task requires to run.
abstract Task.Builder | setRequiresCharging(boolean requiresCharging) Set whether your task requires that the device be connected to power in order to execute.
abstract Task.Builder | setService(Class<? extends GcmTaskService> gcmTaskService) Set whichever `GcmTaskService` you implement to execute the logic for this task.
abstract Task.Builder | setTag(String tag) Mandatory setter for specifying the tag identifer for this task.
abstract Task.Builder | setUpdateCurrent(boolean updateCurrent) Optional setter to specify whether this task should override any preexisting tasks with the same tag.
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Public Constructors

#### public OneoffTask.Builder ()

## Public Methods

#### public OneoffTask build ()

#### public OneoffTask.Builder setExecutionWindow (long windowStartDelaySeconds, long windowEndDelaySeconds)

Mandatory setter for creating a one-off task. You specify the earliest point in time in the future from which your task might start executing, as well as the latest point in time in the future at which your task must have executed.

##### Parameters

windowStartDelaySeconds | Earliest point from which your task is eligible to run.
windowEndDelaySeconds | Latest point at which your task must be run.

#### public OneoffTask.Builder setExtras (Bundle extras)

Optional setter for specifying any extra parameters necessary for the task.

#### public OneoffTask.Builder setPersisted (boolean isPersisted)

Optional setter to specify whether this task should be persisted across reboots. Defaults to false. Callers must hold the permission android.Manifest.permission.RECEIVE_BOOT_COMPLETED, otherwise this setting is ignored.

##### Parameters

isPersisted | True if this task should be persisted across device reboots.

#### public OneoffTask.Builder setRequiredNetwork (int requiredNetworkState)

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.

#### public OneoffTask.Builder setRequiresCharging (boolean requiresCharging)

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.

#### public OneoffTask.Builder setService (Class<? extends GcmTaskService> gcmTaskService)

Set whichever `GcmTaskService` you implement to execute the logic for this task.

##### Parameters

gcmTaskService | Endpoint against which you're scheduling this task.

#### public OneoffTask.Builder setTag (String tag)

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 identifier for this task. Consecutive schedule calls for the same tag will update any preexisting task with the same tag.

#### public OneoffTask.Builder setUpdateCurrent (boolean updateCurrent)

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 | True to update the current task with the parameters of the new. Default false.

## Protected Methods

#### protected void checkConditions ()