public final class CancellationSignal extends Object
CancellationSignal
.
Used to write apps that run on platforms prior to Android 4.1. See the framework SDK
documentation for a class overview.Modifier and Type | Class and Description |
---|---|
static interface |
CancellationSignal.OnCancelListener
Listens for cancellation.
|
Constructor and Description |
---|
CancellationSignal()
Creates a cancellation signal, initially not canceled.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the operation and signals the cancellation listener.
|
Object |
getCancellationSignalObject()
Gets the framework
CancellationSignal associated with this object. |
boolean |
isCanceled()
Returns true if the operation has been canceled.
|
void |
setOnCancelListener(CancellationSignal.OnCancelListener listener)
Sets the cancellation listener to be called when canceled.
|
void |
throwIfCanceled()
Throws
OperationCanceledException if the operation has been canceled. |
public CancellationSignal()
public boolean isCanceled()
public void throwIfCanceled()
OperationCanceledException
if the operation has been canceled.OperationCanceledException
- if the operation has been canceled.public void cancel()
public void setOnCancelListener(CancellationSignal.OnCancelListener listener)
cancel()
has already been called, then the provided
listener is invoked immediately.
This method is guaranteed that the listener will not be called after it
has been removed.listener
- The cancellation listener, or null to remove the current listener.public Object getCancellationSignalObject()
CancellationSignal
associated with this object.
Framework support for cancellation signals was added in
Build.VERSION_CODES.JELLY_BEAN
so this method will always
return null on older versions of the platform.