code: public static <TResult> Task<Task<TResult>> whenAnyResult(Collection<? extends Task<TResult>> tasks) {
      if (tasks.size() == 0) {
        return Task.forResult(null);
      }
  
      final bolts.TaskCompletionSource<Task<TResult>> firstCompleted = new bolts.TaskCompletionSource<>();
      final AtomicBoolean isAnyTaskComplete = new AtomicBoolean(false);
  
      for (Task<TResult> task : tasks) {
        task.continueWith(new Continuation<TResult, Void>() {
          @Override
          public Void then(Task<TResult> task) {
            if (isAnyTaskComplete.compareAndSet(false, true)) {
              firstCompleted.setResult(task);
            } else {
              Throwable ensureObserved = task.getError();
            }
            return null;
          }
        });
      }
      return firstCompleted.getTask();
    }
docs: Creates a task that will complete when any of the supplied tasks have completed.
  <p/>
  The returned task will complete when any of the supplied tasks has completed. The returned task
  will always end in the completed state with its result set to the first task to complete. This
  is true even if the first task to complete ended in the canceled or faulted state.
  
  @param tasks
  The tasks to wait on for completion.
  @return A task that represents the completion of one of the supplied tasks.
  The return task's result is the task that completed.