Summary: Methods | Inherited Methods | [Expand All]
public final class

# Tasks

extends Object

java.lang.Object
↳ | com.google.android.gms.tasks.Tasks

## Class Overview

`Task` utility methods.

## Summary

Public Methods
static <TResult> TResult | await(Task<TResult> task, long timeout, TimeUnit unit) Blocks until the specified Task is complete.
static <TResult> TResult | await(Task<TResult> task) Blocks until the specified Task is complete.
static <TResult> Task<TResult> | call(Callable<TResult> callable) Returns a Task that will be completed with the result of the specified Callable.
static <TResult> Task<TResult> | call(Executor executor, Callable<TResult> callable) Returns a Task that will be completed with the result of the specified Callable.
static <TResult> Task<TResult> | forException(Exception e) Returns a completed Task with the specified exception.
static <TResult> Task<TResult> | forResult(TResult result) Returns a completed Task with the specified result.
static Task<Void> | whenAll(Collection<? extends Task<?>> tasks) Returns a Task that completes successfully when all of the specified Tasks complete successfully.
static Task<Void> | whenAll(Task...<?> tasks) Returns a Task that completes successfully when all of the specified Tasks complete successfully.

[Expand] Inherited Methods
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 Methods

#### public static TResult await (Task<TResult> task, long timeout, TimeUnit unit)

Blocks until the specified Task is complete.

##### Returns

- the Task's result

##### Throws

ExecutionException | if the Task fails
InterruptedException | if an interrupt occurs while waiting for the Task to complete
TimeoutException | if the specified timeout is reached before the Task completes

#### public static TResult await (Task<TResult> task)

Blocks until the specified Task is complete.

##### Returns

- the Task's result

##### Throws

ExecutionException | if the Task fails
InterruptedException | if an interrupt occurs while waiting for the Task to complete

#### public static Task<TResult> call (Callable<TResult> callable)

Returns a Task that will be completed with the result of the specified Callable.

The Callable will be called on the main application thread.

#### public static Task<TResult> call (Executor executor, Callable<TResult> callable)

Returns a Task that will be completed with the result of the specified Callable.

##### Parameters

executor | the Executor to use to call the Callable

#### public static Task<TResult> forException (Exception e)

Returns a completed Task with the specified exception.

#### public static Task<TResult> forResult (TResult result)

Returns a completed Task with the specified result.

#### public static Task<Void> whenAll (Collection<? extends Task<?>> tasks)

Returns a Task that completes successfully when all of the specified Tasks complete successfully. Does not accept nulls.

##### Throws

NullPointerException | if any of the provided Tasks are null

#### public static Task<Void> whenAll (Task...<?> tasks)

Returns a Task that completes successfully when all of the specified Tasks complete successfully. Does not accept nulls.

##### Throws

NullPointerException | if any of the provided Tasks are null