Batch

public final class Batch extends PendingResult


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 but not both.

Summary

Nested types

public final class Batch.Builder

Builder for Batch objects.

Public methods

void

Requests that the batch be canceled.

Inherited methods

From com.google.android.gms.common.api.PendingResult
abstract @NonNull R
await(long time, @NonNull TimeUnit units)

Blocks until the task is completed or has timed out waiting for the result.

abstract void

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

abstract void
setResultCallback(
    @NonNull ResultCallback<R> callback,
    long time,
    @NonNull 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.

@NonNull TransformedResult<S>
<S extends Result> then(@NonNull ResultTransform<R, S> transform)

Transforms the result by making another API call.

Public methods

cancel

public void cancel()

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

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