CancellationSignal
class CancellationSignal
kotlin.Any | |
↳ | androidx.core.os.CancellationSignal |
Static library support version of the framework's android.os.CancellationSignal
. Used to write apps that run on platforms prior to Android 4.1. See the framework SDK documentation for a class overview.
Summary
Nested classes | |
---|---|
abstract |
Listens for cancellation. |
Public constructors | |
---|---|
<init>() Creates a cancellation signal, initially not canceled. |
Public methods | |
---|---|
Unit |
cancel() Cancels the operation and signals the cancellation listener. |
Any? |
Gets the framework |
Boolean |
Returns true if the operation has been canceled. |
Unit |
setOnCancelListener(@Nullable listener: CancellationSignal.OnCancelListener?) Sets the cancellation listener to be called when canceled. |
Unit |
Throws |
Public constructors
<init>
CancellationSignal()
Creates a cancellation signal, initially not canceled.
Public methods
cancel
fun cancel(): Unit
Cancels the operation and signals the cancellation listener. If the operation has not yet started, then it will be canceled as soon as it does.
getCancellationSignalObject
@Nullable fun getCancellationSignalObject(): Any?
Gets the framework android.os.CancellationSignal
associated with this object.
Framework support for cancellation signals was added in android.os.Build.VERSION_CODES#JELLY_BEAN
so this method will always return null on older versions of the platform.
Return | |
---|---|
Any? |
A framework cancellation signal object, or null on platform versions prior to Jellybean. |
isCanceled
fun isCanceled(): Boolean
Returns true if the operation has been canceled.
Return | |
---|---|
Boolean |
True if the operation has been canceled. |
setOnCancelListener
fun setOnCancelListener(@Nullable listener: CancellationSignal.OnCancelListener?): Unit
Sets the cancellation listener to be called when canceled. This method is intended to be used by the recipient of a cancellation signal such as a database or a content provider to handle cancellation requests while performing a long-running operation. This method is not intended to be used by applications themselves. If CancellationSignal#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.
Parameters | |
---|---|
listener |
CancellationSignal.OnCancelListener?: The cancellation listener, or null to remove the current listener. |
throwIfCanceled
fun throwIfCanceled(): Unit
Throws OperationCanceledException
if the operation has been canceled.
Exceptions | |
---|---|
OperationCanceledException |
if the operation has been canceled. |