# Tasks

Summary:[Methods](https://developer.android.com/reference/com/google/android/play/core/tasks/Tasks#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/com/google/android/play/core/tasks/Tasks#inhmethods)  

# Tasks

`
public

final

class
Tasks
`  
`

extends Object


``


`

|---|------------------------------------------|
| java.lang.Object                            ||
| ↳ | com.google.android.play.core.tasks.Tasks |

<br />

*** ** * ** ***

[Task](https://developer.android.com/reference/com/google/android/play/core/tasks/Task.html)utility methods.

## Summary

|                                                                                                                                                                                                                                                               ### Public methods                                                                                                                                                                                                                                                                ||
|----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static <ResultT> ResultT`                                                                                    | ` `[await](https://developer.android.com/reference/com/google/android/play/core/tasks/Tasks.html#await(com.google.android.play.core.tasks.Task<ResultT>,%20long,%20java.util.concurrent.TimeUnit))`(`[Task](https://developer.android.com/reference/com/google/android/play/core/tasks/Task.html)`<ResultT> task, long timeout, TimeUnit unit) ` Blocks until the specified Task is complete.                                   |
| ` static <ResultT> ResultT`                                                                                    | ` `[await](https://developer.android.com/reference/com/google/android/play/core/tasks/Tasks.html#await(com.google.android.play.core.tasks.Task<ResultT>))`(`[Task](https://developer.android.com/reference/com/google/android/play/core/tasks/Task.html)`<ResultT> task) ` Blocks until the specified Task is complete.                                                                                                         |
| ` static `[Task](https://developer.android.com/reference/com/google/android/play/core/tasks/Task.html)`<Void>` | ` `[whenAll](https://developer.android.com/reference/com/google/android/play/core/tasks/Tasks.html#whenAll(java.util.Collection<?%20extends%20com.google.android.play.core.tasks.Task<?>>))`(Collection<? extends `[Task](https://developer.android.com/reference/com/google/android/play/core/tasks/Task.html)`<?>> tasks) ` Returns a Task that completes successfully when all of the specified Tasks complete successfully. |

| ### Inherited methods |
|-----------------------|---|
| From class` java.lang.Object ` |-------------------|-------------------------------| | ` boolean`        | ` equals(Object arg0) `       | | ` 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

### await

```
public static ResultT await (Task<ResultT> task, 
                long timeout, 
                TimeUnit unit)
```

Blocks until the specified Task is complete.

<br />

|          Parameters          ||
|-----------|-------------------|
| `task`    | `Task` <br />     |
| `timeout` | `long` <br />     |
| `unit`    | `TimeUnit` <br /> |

|               Returns               ||
|-----------|--------------------------|
| `ResultT` | the Task's result <br /> |

|                                        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 |

### await

```
public static ResultT await (Task<ResultT> task)
```

Blocks until the specified Task is complete.

<br />

|      Parameters       ||
|--------|---------------|
| `task` | `Task` <br /> |

|               Returns               ||
|-----------|--------------------------|
| `ResultT` | the Task's result <br /> |

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

### whenAll

```
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.

The returned Task would fail if any of the provided Tasks fail.

<br />

|          Parameters          ||
|---------|---------------------|
| `tasks` | `Collection` <br /> |

|                                                   Returns                                                    ||
|------------------------------------------------------------------------------------------------------|--------|
| [Task](https://developer.android.com/reference/com/google/android/play/core/tasks/Task.html)`<Void>` | <br /> |

|                            Throws                             ||
|------------------------|---------------------------------------|
| `NullPointerException` | if any of the provided Tasks are null |