Stay organized with collections
Save and categorize content based on your preferences.
Tasks
public
final
class
Tasks
extends Object
java.lang.Object
|
↳ |
com.google.android.play.core.tasks.Tasks
|
Task
utility methods.
Summary
Public methods |
static
<ResultT>
ResultT
|
await(Task<ResultT> task, long timeout, TimeUnit unit)
Blocks until the specified Task is complete.
|
static
<ResultT>
ResultT
|
await(Task<ResultT> task)
Blocks until the specified Task is complete.
|
static
Task<Void>
|
whenAll(Collection<? extends Task<?>> 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.
Parameters |
task |
Task |
timeout |
long |
unit |
TimeUnit |
Returns |
ResultT |
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
|
await
public static ResultT await (Task<ResultT> task)
Blocks until the specified Task is complete.
Returns |
ResultT |
the Task's result |
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.
Parameters |
tasks |
Collection |
Throws |
NullPointerException |
if any of the provided Tasks are null
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Tasks\n\nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nTasks\n=====\n\n\n`\npublic\n\nfinal\n\nclass\nTasks\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\n`\n\n|---|------------------------------------------|\n| java.lang.Object ||\n| ↳ | com.google.android.play.core.tasks.Tasks |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\n[Task](../../../../../../../reference/com/google/android/play/core/tasks/Task.html) utility methods.\n\nSummary\n-------\n\n| ### Public methods ||\n|-------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` static \u003cResultT\u003e ResultT` | ` `[await](../../../../../../../reference/com/google/android/play/core/tasks/Tasks.html#await(com.google.android.play.core.tasks.Task\u003cResultT\u003e,%20long,%20java.util.concurrent.TimeUnit))`(`[Task](../../../../../../../reference/com/google/android/play/core/tasks/Task.html)`\u003cResultT\u003e task, long timeout, TimeUnit unit) ` Blocks until the specified Task is complete. |\n| ` static \u003cResultT\u003e ResultT` | ` `[await](../../../../../../../reference/com/google/android/play/core/tasks/Tasks.html#await(com.google.android.play.core.tasks.Task\u003cResultT\u003e))`(`[Task](../../../../../../../reference/com/google/android/play/core/tasks/Task.html)`\u003cResultT\u003e task) ` Blocks until the specified Task is complete. |\n| ` static `[Task](../../../../../../../reference/com/google/android/play/core/tasks/Task.html)`\u003cVoid\u003e` | ` `[whenAll](../../../../../../../reference/com/google/android/play/core/tasks/Tasks.html#whenAll(java.util.Collection\u003c?%20extends%20com.google.android.play.core.tasks.Task\u003c?\u003e\u003e))`(Collection\u003c? extends `[Task](../../../../../../../reference/com/google/android/play/core/tasks/Task.html)`\u003c?\u003e\u003e tasks) ` Returns a Task that completes successfully when all of the specified Tasks complete successfully. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` java.lang.Object ` |-------------------|-------------------------------| | ` boolean` | ` equals(Object arg0) ` | | ` final Class\u003c?\u003e` | ` 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() ` | ||\n\nPublic methods\n--------------\n\n### await\n\n```\npublic static ResultT await (Task\u003cResultT\u003e task, \n long timeout, \n TimeUnit unit)\n```\n\nBlocks until the specified Task is complete.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|-------------------|\n| `task` | `Task` \u003cbr /\u003e |\n| `timeout` | `long` \u003cbr /\u003e |\n| `unit` | `TimeUnit` \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------------------------|\n| `ResultT` | the Task's result \u003cbr /\u003e |\n\n| Throws ||\n|------------------------|---------------------------------------------------------------|\n| `ExecutionException` | if the Task fails |\n| `InterruptedException` | if an interrupt occurs while waiting for the Task to complete |\n| `TimeoutException` | if the specified timeout is reached before the Task completes |\n\n### await\n\n```\npublic static ResultT await (Task\u003cResultT\u003e task)\n```\n\nBlocks until the specified Task is complete.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|---------------|\n| `task` | `Task` \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------------------------|\n| `ResultT` | the Task's result \u003cbr /\u003e |\n\n| Throws ||\n|------------------------|---------------------------------------------------------------|\n| `ExecutionException` | if the Task fails |\n| `InterruptedException` | if an interrupt occurs while waiting for the Task to complete |\n\n### whenAll\n\n```\npublic static Task\u003cVoid\u003e whenAll (Collection\u003c? extends Task\u003c?\u003e\u003e tasks)\n```\n\nReturns a Task that completes successfully when all of the specified Tasks complete\nsuccessfully. Does not accept nulls.\n\nThe returned Task would fail if any of the provided Tasks fail.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|---------------------|\n| `tasks` | `Collection` \u003cbr /\u003e |\n\n| Returns ||\n|---------------------------------------------------------------------------------------------|--------|\n| [Task](../../../../../../../reference/com/google/android/play/core/tasks/Task.html)`\u003cVoid\u003e` | \u003cbr /\u003e |\n\n| Throws ||\n|------------------------|---------------------------------------|\n| `NullPointerException` | if any of the provided Tasks are null |"]]