Android APIs
public final class

CancellationSignal

extends Object
java.lang.Object
   ↳ android.support.v4.os.CancellationSignal

Class Overview

Static library support version of the framework's 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
interface CancellationSignal.OnCancelListener Listens for cancellation. 
Public Constructors
CancellationSignal()
Creates a cancellation signal, initially not canceled.
Public Methods
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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public CancellationSignal ()

Creates a cancellation signal, initially not canceled.

Public Methods

public void cancel ()

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.

public Object getCancellationSignalObject ()

Gets the framework CancellationSignal associated with this object.

Framework support for cancellation signals was added in JELLY_BEAN so this method will always return null on older versions of the platform.

Returns
  • A framework cancellation signal object, or null on platform versions prior to Jellybean.

public boolean isCanceled ()

Returns true if the operation has been canceled.

Returns
  • True if the operation has been canceled.

public void setOnCancelListener (CancellationSignal.OnCancelListener listener)

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 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 The cancellation listener, or null to remove the current listener.

public void throwIfCanceled ()

Throws OperationCanceledException if the operation has been canceled.

Throws
OperationCanceledException if the operation has been canceled.