Summary: Nested Classes | Fields | Protected Ctors | Methods | Protected Methods | Inherited Methods | [Expand All]
public abstract class

# StorageTask

extends ControllableTask<TResult extends StorageTask.ProvideError>

java.lang.Object
↳ | com.google.android.gms.tasks.Task<TResult extends com.google.firebase.storage.StorageTask.ProvideError>
| ↳ | com.google.firebase.storage.CancellableTask<TResult extends com.google.firebase.storage.StorageTask.ProvideError>
|  | ↳ | com.google.firebase.storage.ControllableTask<TResult extends com.google.firebase.storage.StorageTask.ProvideError>
|  |  | ↳ | com.google.firebase.storage.StorageTask<TResult extends com.google.firebase.storage.StorageTask.ProvideError>

Known Direct Subclasses FileDownloadTask, StreamDownloadTask, UploadTask
FileDownloadTask | A task that downloads bytes of a GCS blob to a specified File.
StreamDownloadTask | A task that downloads bytes of a GCS blob.
UploadTask | An controllable task that uploads and fires events for success, progress and failure.

## Class Overview

A controllable Task that has a synchronized state machine.

## Summary

Nested Classes
interface | StorageTask.ProvideError | an object that returns an exception.

Fields
protected final Object | mSyncObject |

Protected Constructors
| StorageTask()

Public Methods
StorageTask<TResult> | addOnFailureListener(Activity activity, OnFailureListener listener) Adds a listener that is called if the Task fails.
StorageTask<TResult> | addOnFailureListener(OnFailureListener listener) Adds a listener that is called if the Task fails.
StorageTask<TResult> | addOnFailureListener(Executor executor, OnFailureListener listener) Adds a listener that is called if the Task fails.
StorageTask<TResult> | addOnPausedListener(Executor executor, OnPausedListener<? super TResult> listener) Adds a listener that is called when the Task becomes paused.
StorageTask<TResult> | addOnPausedListener(Activity activity, OnPausedListener<? super TResult> listener) Adds a listener that is called when the Task becomes paused.
StorageTask<TResult> | addOnPausedListener(OnPausedListener<? super TResult> listener) Adds a listener that is called when the Task becomes paused.
StorageTask<TResult> | addOnProgressListener(Executor executor, OnProgressListener<? super TResult> listener) Adds a listener that is called periodically while the ControllableTask executes.
StorageTask<TResult> | addOnProgressListener(OnProgressListener<? super TResult> listener) Adds a listener that is called periodically while the ControllableTask executes.
StorageTask<TResult> | addOnProgressListener(Activity activity, OnProgressListener<? super TResult> listener) Adds a listener that is called periodically while the ControllableTask executes.
StorageTask<TResult> | addOnSuccessListener(OnSuccessListener<? super TResult> listener) Adds a listener that is called if the Task completes successfully.
StorageTask<TResult> | addOnSuccessListener(Activity activity, OnSuccessListener<? super TResult> listener) Adds a listener that is called if the Task completes successfully.
StorageTask<TResult> | addOnSuccessListener(Executor executor, OnSuccessListener<? super TResult> listener) Adds a listener that is called if the Task completes successfully.
boolean | cancel() Attempts to cancel the task.
Exception | getException() Returns the exception that caused the Task to fail.
TResult | getResult() Gets the result of the Task, if it has already completed.
<X extends Throwable> TResult | getResult(Class<X> exceptionType) Gets the result of the Task, if it has already completed.
TResult | getSnapshot()
boolean | isCanceled()
boolean | isComplete() Returns `true` if the Task is complete; `false` otherwise.
boolean | isInProgress()
boolean | isPaused()
boolean | isSuccessful() Returns `true` if the Task has completed successfully; `false` otherwise.
boolean | pause() Attempts to pause the task.
StorageTask<TResult> | removeOnFailureListener(OnFailureListener listener) Removes a listener.
StorageTask<TResult> | removeOnPausedListener(OnPausedListener<? super TResult> listener) Removes a listener.
StorageTask<TResult> | removeOnProgressListener(OnProgressListener<? super TResult> listener) Removes a listener.
StorageTask<TResult> | removeOnSuccessListener(OnSuccessListener<? super TResult> listener) Removes a listener.
boolean | resume() Attempts to resume a paused task.

Protected Methods
void | onCanceled()
void | onFailure()
void | onPaused()
void | onProgress()
void | onQueued()
void | onSuccess()

[Expand] Inherited Methods
From class com.google.firebase.storage.ControllableTask
abstract ControllableTask<TResult extends StorageTask.ProvideError> | addOnPausedListener(Activity activity, OnPausedListener<? super TState> listener) Adds a listener that is called when the Task becomes paused.
abstract ControllableTask<TResult extends StorageTask.ProvideError> | addOnPausedListener(OnPausedListener<? super TState> listener) Adds a listener that is called when the Task becomes paused.
abstract ControllableTask<TResult extends StorageTask.ProvideError> | addOnPausedListener(Executor executor, OnPausedListener<? super TState> listener) Adds a listener that is called when the Task becomes paused.
abstract boolean | isPaused()
abstract boolean | pause() Attempts to pause the task.
abstract boolean | resume() Attempts to resume this task.
From class com.google.firebase.storage.CancellableTask
abstract CancellableTask<TResult extends StorageTask.ProvideError> | addOnProgressListener(OnProgressListener<? super TState> listener) Adds a listener that is called periodically while the ControllableTask executes.
abstract CancellableTask<TResult extends StorageTask.ProvideError> | addOnProgressListener(Executor executor, OnProgressListener<? super TState> listener) Adds a listener that is called periodically while the ControllableTask executes.
abstract CancellableTask<TResult extends StorageTask.ProvideError> | addOnProgressListener(Activity activity, OnProgressListener<? super TState> listener) Adds a listener that is called periodically while the ControllableTask executes.
abstract boolean | cancel() Attempts to cancel the task.
abstract boolean | isCanceled()
abstract boolean | isInProgress()
From class com.google.android.gms.tasks.Task
Task<TResult> | addOnCompleteListener(OnCompleteListener<TResult> listener) Adds a listener that is called when the Task completes.
Task<TResult> | addOnCompleteListener(Activity activity, OnCompleteListener<TResult> listener) Adds an Activity-scoped listener that is called when the Task completes.
Task<TResult> | addOnCompleteListener(Executor executor, OnCompleteListener<TResult> listener) Adds a listener that is called when the Task completes.
abstract Task<TResult> | addOnFailureListener(Activity activity, OnFailureListener listener) Adds an Activity-scoped listener that is called if the Task fails.
abstract Task<TResult> | addOnFailureListener(OnFailureListener listener) Adds a listener that is called if the Task fails.
abstract Task<TResult> | addOnFailureListener(Executor executor, OnFailureListener listener) Adds a listener that is called if the Task fails.
abstract Task<TResult> | addOnSuccessListener(Executor executor, OnSuccessListener<? super TResult> listener) Adds a listener that is called if the Task completes successfully.
abstract Task<TResult> | addOnSuccessListener(OnSuccessListener<? super TResult> listener) Adds a listener that is called if the Task completes successfully.
abstract Task<TResult> | addOnSuccessListener(Activity activity, OnSuccessListener<? super TResult> listener) Adds an Activity-scoped listener that is called if the Task completes successfully.
<TContinuationResult> Task<TContinuationResult> | continueWith(Continuation<TResult, TContinuationResult> continuation) Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.
<TContinuationResult> Task<TContinuationResult> | continueWith(Executor executor, Continuation<TResult, TContinuationResult> continuation) Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.
<TContinuationResult> Task<TContinuationResult> | continueWithTask(Continuation<TResult, Task<TContinuationResult>> continuation) Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.
<TContinuationResult> Task<TContinuationResult> | continueWithTask(Executor executor, Continuation<TResult, Task<TContinuationResult>> continuation) Returns a new Task that will be completed with the result of applying the specified Continuation to this Task.
abstract Exception | getException() Returns the exception that caused the Task to fail.
abstract TResult | getResult() Gets the result of the Task, if it has already completed.
abstract <X extends Throwable> TResult | getResult(Class<X> exceptionType) Gets the result of the Task, if it has already completed.
abstract boolean | isComplete() Returns `true` if the Task is complete; `false` otherwise.
abstract boolean | isSuccessful() Returns `true` if the Task has completed successfully; `false` otherwise.
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()

## Fields

#### protected final Object mSyncObject

## Protected Constructors

#### protected StorageTask ()

## Public Methods

#### public StorageTask<TResult> addOnFailureListener (Activity activity, OnFailureListener listener)

Adds a listener that is called if the Task fails.

If the task has already failed, a call to the listener will be immediately scheduled. If multiple listeners are added, they will be called in the order in which they were added.

##### Parameters

activity | When the supplied `Activity` stops, this listener will automatically be removed.

##### Returns

- this Task

#### public StorageTask<TResult> addOnFailureListener (OnFailureListener listener)

Adds a listener that is called if the Task fails.

The listener will be called on main application thread. If the task has already failed, a call to the listener will be immediately scheduled. If multiple listeners are added, they will be called in the order in which they were added.

##### Returns

- this Task

#### public StorageTask<TResult> addOnFailureListener (Executor executor, OnFailureListener listener)

Adds a listener that is called if the Task fails.

If the task has already failed, a call to the listener will be immediately scheduled. If multiple listeners are added, they will be called in the order in which they were added.

##### Parameters

executor | the executor to use to call the listener

##### Returns

- this Task

#### public StorageTask<TResult> addOnPausedListener (Executor executor, OnPausedListener<? super TResult> listener)

Adds a listener that is called when the Task becomes paused.

##### Parameters

executor | the executor to use to call the listener

##### Returns

- this Task

#### public StorageTask<TResult> addOnPausedListener (Activity activity, OnPausedListener<? super TResult> listener)

Adds a listener that is called when the Task becomes paused.

##### Parameters

activity | When the supplied `Activity` stops, this listener will automatically be removed.

##### Returns

- this Task

#### public StorageTask<TResult> addOnPausedListener (OnPausedListener<? super TResult> listener)

Adds a listener that is called when the Task becomes paused.

##### Returns

- this Task

#### public StorageTask<TResult> addOnProgressListener (Executor executor, OnProgressListener<? super TResult> listener)

Adds a listener that is called periodically while the ControllableTask executes.

##### Parameters

executor | the executor to use to call the listener

##### Returns

- this Task

#### public StorageTask<TResult> addOnProgressListener (OnProgressListener<? super TResult> listener)

Adds a listener that is called periodically while the ControllableTask executes.

##### Returns

- this Task

#### public StorageTask<TResult> addOnProgressListener (Activity activity, OnProgressListener<? super TResult> listener)

Adds a listener that is called periodically while the ControllableTask executes.

##### Parameters

activity | When the supplied `Activity` stops, this listener will automatically be removed.

##### Returns

- this Task

#### public StorageTask<TResult> addOnSuccessListener (OnSuccessListener<? super TResult> listener)

Adds a listener that is called if the Task completes successfully.

The listener will be called on the main application thread. If the task has already completed successfully, a call to the listener will be immediately scheduled. If multiple listeners are added, they will be called in the order in which they were added.

##### Returns

- this Task

#### public StorageTask<TResult> addOnSuccessListener (Activity activity, OnSuccessListener<? super TResult> listener)

Adds a listener that is called if the Task completes successfully.

If multiple listeners are added, they will be called in the order in which they were added. If the task has already completed successfully, a call to the listener will be immediately scheduled.

##### Parameters

activity | When the supplied `Activity` stops, this listener will automatically be removed.

##### Returns

- this Task

#### public StorageTask<TResult> addOnSuccessListener (Executor executor, OnSuccessListener<? super TResult> listener)

Adds a listener that is called if the Task completes successfully.

If multiple listeners are added, they will be called in the order in which they were added. If the task has already completed successfully, a call to the listener will be immediately scheduled.

##### Parameters

executor | the executor to use to call the listener

##### Returns

- this Task

#### public boolean cancel ()

Attempts to cancel the task. A canceled task cannot be resumed later.

##### Returns

- true if this task is successfully being canceled.

#### public Exception getException ()

Returns the exception that caused the Task to fail. Returns `null` if the Task is not yet complete, or completed successfully.

#### public TResult getResult ()

Gets the result of the Task, if it has already completed.

##### Throws

IllegalStateException | if the Task is not yet complete
RuntimeExecutionException | if the Task failed with an exception

#### public TResult getResult (Class<X> exceptionType)

Gets the result of the Task, if it has already completed.

##### Throws

IllegalStateException | if the Task is not yet complete
| if the Task failed with an exception of type X
RuntimeExecutionException | if the Task failed with an exception that was not of type X
Throwable |

#### public TResult getSnapshot ()

##### Returns

- the current state of the task. This method will return state at any point of the tasks execution and may not be the final result..

#### public boolean isCanceled ()

##### Returns

- true if the task has been canceled.

#### public boolean isComplete ()

Returns `true` if the Task is complete; `false` otherwise.

#### public boolean isInProgress ()

##### Returns

- true if the task is currently running.

#### public boolean isPaused ()

##### Returns

- true if the task has been paused.

#### public boolean isSuccessful ()

Returns `true` if the Task has completed successfully; `false` otherwise.

#### public boolean pause ()

Attempts to pause the task. A paused task can later be resumed.

##### Returns

- true if this task is successfully being paused. Note that a task may not be immediately paused if it was executing another action and can still fail or complete.

#### public StorageTask<TResult> removeOnFailureListener (OnFailureListener listener)

Removes a listener.

#### public StorageTask<TResult> removeOnPausedListener (OnPausedListener<? super TResult> listener)

Removes a listener.

#### public StorageTask<TResult> removeOnProgressListener (OnProgressListener<? super TResult> listener)

Removes a listener.

#### public StorageTask<TResult> removeOnSuccessListener (OnSuccessListener<? super TResult> listener)

Removes a listener.

#### public boolean resume ()

Attempts to resume a paused task.

##### Returns

- true if the task is successfully resumed. false if the task has an unrecoverable error or has entered another state that precludes resume.

## Protected Methods

#### protected void onCanceled ()

#### protected void onFailure ()

#### protected void onPaused ()

#### protected void onProgress ()

#### protected void onQueued ()

#### protected void onSuccess ()