public final class

Batch

extends PendingResult<R extends Result>
java.lang.Object
   ↳ com.google.android.gms.common.api.PendingResult<R extends com.google.android.gms.common.api.Result>
     ↳ com.google.android.gms.common.api.Batch

Class Overview

Handles a batch of PendingResult items. Callbacks can be added and you can block to wait for all items in the batch to complete like any other PendingResult item. A Batch can also be canceled if the results are no longer needed. In this case, the onBatchComplete callback will never be triggered.

The results can be taken either from the underlying PendingResults or via take(BatchResultToken) but not both.

Summary

Nested Classes
class Batch.Builder Builder for Batch objects. 
Fields
protected final WeakReference<GoogleApiClient> mApiClient This reference will never be null so long as the GoogleApiClient is connected.
Public Methods
final R extends Result await()
Blocks until the task is completed.
final R extends Result await(long time, TimeUnit units)
Blocks until the task is completed or has timed out waiting for the result.
void cancel()
Requests that the batch be canceled.
void clearResultCallback()
BatchResult createFailedResult(Status status)
Creates a result of type <R> that represents a failure with the specified Status.
boolean isCanceled()
Indicates whether the pending result has been canceled either due to calling disconnect() or calling cancel() directly on the pending result or an enclosing Batch.
final void setResultCallback(ResultCallback<? super R extends Result> callback)
Set the callback here if you want the result to be delivered via a callback when the result is ready.
final void setResultCallback(ResultCallback<? super R extends Result> callback, long time, TimeUnit units)
Set the callback here if you want the result to be delivered via a callback when the result is ready or has timed out waiting for the result.
[Expand]
Inherited Methods
From class com.google.android.gms.common.api.PendingResult
From class java.lang.Object

Fields

protected final WeakReference<GoogleApiClient> mApiClient

This reference will never be null so long as the GoogleApiClient is connected. It needs to be weak so that PendingResults don't pin disconnected GACs due to binder references to the PendingResults.

Public Methods

public final R extends Result await ()

Blocks until the task is completed. This is not allowed on the UI thread. The returned result object can have an additional failure mode of INTERRUPTED.

Returns
R extends Result

public final R extends Result await (long time, TimeUnit units)

Blocks until the task is completed or has timed out waiting for the result. This is not allowed on the UI thread. The returned result object can have an additional failure mode of either INTERRUPTED or TIMEOUT.

Parameters
time long
units TimeUnit
Returns
R extends Result

public void cancel ()

Requests that the batch be canceled. Cancels all underlying PendingResults.

onResult(Result) will never be called, await() will return a failed result with status CANCELED.

public void clearResultCallback ()

public BatchResult createFailedResult (Status status)

Creates a result of type <R> that represents a failure with the specified Status.

Parameters
status Status
Returns
BatchResult

public boolean isCanceled ()

Indicates whether the pending result has been canceled either due to calling disconnect() or calling cancel() directly on the pending result or an enclosing Batch.

Returns
boolean

public final void setResultCallback (ResultCallback<? super R extends Result> callback)

Set the callback here if you want the result to be delivered via a callback when the result is ready.

Parameters
callback ResultCallback

public final void setResultCallback (ResultCallback<? super R extends Result> callback, long time, TimeUnit units)

Set the callback here if you want the result to be delivered via a callback when the result is ready or has timed out waiting for the result. The returned result object can have an additional failure mode of TIMEOUT.

Parameters
callback ResultCallback
time long
units TimeUnit