OptionalPendingResult

public abstract class OptionalPendingResult<R extends Result> extends PendingResult


Each OptionalPendingResult is a PendingResult with additional support for non-blocking accessors. The result of an OptionalPendingResult may be available immediately. If the result is available isDone will return true.

Parameters
<R extends Result>

Result returned by various accessors.

Summary

Public constructors

Public methods

abstract R
get()

Returns the Result immediately if it is available.

abstract boolean

Returns true if the result is available immediately, false otherwise.

Inherited methods

From com.google.android.gms.common.api.PendingResult
abstract @NonNull R

Blocks until the task is completed.

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

Requests that the PendingResult be canceled.

abstract boolean

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.

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<Object> 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<Object, S> transform)

Transforms the result by making another API call.

Public constructors

OptionalPendingResult

public OptionalPendingResult()

Public methods

get

public abstract R get()

Returns the Result immediately if it is available. If the result is not available, an exception will be thrown. This method should only be called after checking that isDone returns true.

After the result has been retrieved using get, await, or has been delivered to the result callback, it is an error to attempt to retrieve the result again. It is the responsibility of the caller or callback receiver to release any resources associated with the returned result. Some result types may implement Releasable, in which case release should be used to free the associated resources.

Throws
java.lang.IllegalStateException

when the result is not isDone.

isDone

public abstract boolean isDone()

Returns true if the result is available immediately, false otherwise.