# CancellationSignal

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/os/CancellationSignal.java+class:androidx.core.os.CancellationSignal) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)

*** ** * ** ***


```
class CancellationSignal
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> This class was added to the platform in SDK 16, which is below Jetpack's minimum SDK requirement. Use the platform-supplied version of this class: `https://developer.android.com/reference/android/os/CancellationSignal.html`

Static library support version of the framework's `https://developer.android.com/reference/android/os/CancellationSignal.html`. Used to write apps that run on platforms prior to Android 4.1. See the framework SDK documentation for a class overview.

## Summary

| ### Nested types |
|---|
| `interface https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal.OnCancelListener` **This interface is deprecated.** Deprecated in Java |

| ### Public constructors |
|---|
| `[CancellationSignal](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#CancellationSignal())()` **This function is deprecated.** Deprecated in Java |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[cancel](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#cancel())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | `[getCancellationSignalObject](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#getCancellationSignalObject())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[isCanceled](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#isCanceled())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[setOnCancelListener](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#setOnCancelListener(androidx.core.os.CancellationSignal.OnCancelListener))(listener: https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal.OnCancelListener?)` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[throwIfCanceled](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#throwIfCanceled())()` **This function is deprecated.** Deprecated in Java |

## Public constructors

### CancellationSignal

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)

```
[CancellationSignal](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#CancellationSignal())()
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Creates a cancellation signal, initially not canceled.

## Public functions

### cancel

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)

```
fun [cancel](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#cancel())(): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

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

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)

```
fun [getCancellationSignalObject](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#getCancellationSignalObject())(): Any?
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Gets the framework `https://developer.android.com/reference/android/os/CancellationSignal.html` associated with this object.

Framework support for cancellation signals was added in `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#JELLY_BEAN` so this method will always return null on older versions of the platform.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | A framework cancellation signal object, or null on platform versions prior to Jellybean. |

### isCanceled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)

```
fun [isCanceled](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#isCanceled())(): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Returns true if the operation has been canceled.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if the operation has been canceled. |

### setOnCancelListener

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)

```
fun [setOnCancelListener](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#setOnCancelListener(androidx.core.os.CancellationSignal.OnCancelListener))(listener: CancellationSignal.OnCancelListener?): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

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 `https://developer.android.com/reference/kotlin/androidx/core/os/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: https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal.OnCancelListener?` | The cancellation listener, or null to remove the current listener. |

### throwIfCanceled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)

```
fun [throwIfCanceled](https://developer.android.com/reference/kotlin/androidx/core/os/CancellationSignal#throwIfCanceled())(): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Throws `https://developer.android.com/reference/kotlin/androidx/core/os/OperationCanceledException` if the operation has been canceled.

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/os/OperationCanceledException` | if the operation has been canceled. |