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."],[],[]]