CancellableTask

public abstract class CancellableTask extends Task<TState>
Known Direct Subclasses
Known Indirect Subclasses

Represents an asynchronous operation that can be canceled.

Public Constructor Summary

Public Method Summary

abstract CancellableTask<TState>
addOnProgressListener(OnProgressListener<? super TState> listener)
Adds a listener that is called periodically while the ControllableTask executes.
abstract CancellableTask<TState>
addOnProgressListener(Executor executor, OnProgressListener<? super TState> listener)
Adds a listener that is called periodically while the ControllableTask executes.
abstract CancellableTask<TState>
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
abstract boolean

Inherited Method Summary

Public Constructors

public CancellableTask ()

Public Methods

public abstract CancellableTask<TState> addOnProgressListener (OnProgressListener<? super TState> listener)

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

Returns
  • this Task

public abstract CancellableTask<TState> addOnProgressListener (Executor executor, OnProgressListener<? super TState> 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 abstract CancellableTask<TState> addOnProgressListener (Activity activity, OnProgressListener<? super TState> 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 abstract boolean cancel ()

Attempts to cancel the task. A canceled task cannot be resumed later. A canceled task calls back on listeners subscribed to addOnFailureListener(OnFailureListener) with an exception that indicates the task was canceled.

Returns
  • true if this task was successfully canceled or is in the process of being canceled. Returns false if the task is already completed or in a state that cannot be canceled.

public abstract boolean isCanceled ()

Returns
  • true if the task has been canceled.

public abstract boolean isInProgress ()

Returns
  • true if the task is currently running.

Send feedback about...

Need help? Visit our support page.