# Loader

Artifact: [androidx.loader:loader](https://developer.android.com/jetpack/androidx/releases/loader) [View Source](https://cs.android.com/search?q=file:androidx/loader/content/Loader.java+class:androidx.loader.content.Loader) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

*** ** * ** ***


```
public class Loader<D>
```

<br />

Known direct subclasses [AsyncTaskLoader](https://developer.android.com/reference/androidx/loader/content/AsyncTaskLoader)

|---|---|
| `https://developer.android.com/reference/androidx/loader/content/AsyncTaskLoader` | Static library support version of the framework's `https://developer.android.com/reference/android/content/AsyncTaskLoader.html`. |

Known indirect subclasses [CursorLoader](https://developer.android.com/reference/androidx/loader/content/CursorLoader)

|---|---|
| `https://developer.android.com/reference/androidx/loader/content/CursorLoader` | Static library support version of the framework's `https://developer.android.com/reference/android/content/CursorLoader.html`. |

*** ** * ** ***

Static library support version of the framework's `https://developer.android.com/reference/android/content/Loader.html`. Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview.

## Summary

| ### Nested types |
|---|
| `public final inner class https://developer.android.com/reference/androidx/loader/content/Loader.ForceLoadContentObserver extends https://developer.android.com/reference/android/database/ContentObserver.html` An implementation of a ContentObserver that takes care of connecting it to the Loader to have the loader re-load its data when the observer is told it has changed. |
| `public interface https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCanceledListener<D>` Interface that is implemented to discover when a Loader has been canceled before it finished loading its data. |
| `public interface https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCompleteListener<D>` Interface that is implemented to discover when a Loader has finished loading its data. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/loader/content/Loader#Loader(android.content.Context)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context)` Stores away the application context associated with context. |

| ### Public methods |
|---|---|
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#abandon()()` This function will normally be called for you automatically by `https://developer.android.com/reference/androidx/loader/app/LoaderManager` when restarting a Loader. |
| `boolean` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#cancelLoad()()` Attempt to cancel the current load task. |
| `void` | `https://developer.android.com/reference/androidx/loader/content/Loader#commitContentChanged()()` Commit that you have actually fully processed a content change that was returned by `https://developer.android.com/reference/androidx/loader/content/Loader#takeContentChanged()`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/loader/content/Loader#dataToString(D)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html D data)` For debugging, converts an instance of the Loader's data class to a string that can be printed. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#deliverCancellation()()` Informs the registered `https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCanceledListener` that the load has been canceled. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#deliverResult(D)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html D data)` Sends the result of the load to the registered listener. |
| `void` | `[dump](https://developer.android.com/reference/androidx/loader/content/Loader#dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[]))( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html prefix, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/io/FileDescriptor.html fd, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/io/PrintWriter.html writer, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html String[] args )` **This method is deprecated.** Consider using `https://developer.android.com/reference/androidx/loader/app/LoaderManager#enableDebugLogging(boolean)` to understand the series of operations performed by LoaderManager. <br /> |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#forceLoad()()` Force an asynchronous load. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html` | `https://developer.android.com/reference/androidx/loader/content/Loader#getContext()()` |
| `int` | `https://developer.android.com/reference/androidx/loader/content/Loader#getId()()` |
| `boolean` | `https://developer.android.com/reference/androidx/loader/content/Loader#isAbandoned()()` Return whether this loader has been abandoned. |
| `boolean` | `https://developer.android.com/reference/androidx/loader/content/Loader#isReset()()` Return whether this load has been reset. |
| `boolean` | `https://developer.android.com/reference/androidx/loader/content/Loader#isStarted()()` Return whether this load has been started. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#onContentChanged()()` Called when `https://developer.android.com/reference/androidx/loader/content/Loader.ForceLoadContentObserver` detects a change. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#registerListener(int,androidx.loader.content.Loader.OnLoadCompleteListener<D>)( int id, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCompleteListener<D> listener )` Registers a class that will receive callbacks when a load is complete. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#registerOnLoadCanceledListener(androidx.loader.content.Loader.OnLoadCanceledListener<D>)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCanceledListener<D> listener )` Registers a listener that will receive callbacks when a load is canceled. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#reset()()` This function will normally be called for you automatically by `https://developer.android.com/reference/androidx/loader/app/LoaderManager` when destroying a Loader. |
| `void` | `https://developer.android.com/reference/androidx/loader/content/Loader#rollbackContentChanged()()` Report that you have abandoned the processing of a content change that was returned by `https://developer.android.com/reference/androidx/loader/content/Loader#takeContentChanged()` and would like to rollback to the state where there is again a pending content change. |
| `final void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#startLoading()()` This function will normally be called for you automatically by `https://developer.android.com/reference/androidx/loader/app/LoaderManager` when the associated fragment/activity is being started. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#stopLoading()()` This function will normally be called for you automatically by `https://developer.android.com/reference/androidx/loader/app/LoaderManager` when the associated fragment/activity is being stopped. |
| `boolean` | `https://developer.android.com/reference/androidx/loader/content/Loader#takeContentChanged()()` Take the current flag indicating whether the loader's content had changed while it was stopped. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/loader/content/Loader#toString()()` |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#unregisterListener(androidx.loader.content.Loader.OnLoadCompleteListener<D>)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCompleteListener<D> listener)` Remove a listener that was previously added with `https://developer.android.com/reference/androidx/loader/content/Loader#registerListener(int,androidx.loader.content.Loader.OnLoadCompleteListener<D>)`. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#unregisterOnLoadCanceledListener(androidx.loader.content.Loader.OnLoadCanceledListener<D>)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCanceledListener<D> listener )` Unregisters a listener that was previously added with `https://developer.android.com/reference/androidx/loader/content/Loader#registerOnLoadCanceledListener(androidx.loader.content.Loader.OnLoadCanceledListener<D>)`. |

| ### Protected methods |
|---|---|
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#onAbandon()()` Subclasses implement this to take care of being abandoned. |
| `boolean` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#onCancelLoad()()` Subclasses must implement this to take care of requests to `https://developer.android.com/reference/androidx/loader/content/Loader#cancelLoad()`. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#onForceLoad()()` Subclasses must implement this to take care of requests to `https://developer.android.com/reference/androidx/loader/content/Loader#forceLoad()`. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#onReset()()` Subclasses must implement this to take care of resetting their loader, as per `https://developer.android.com/reference/androidx/loader/content/Loader#reset()`. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#onStartLoading()()` Subclasses must implement this to take care of loading their data, as per `https://developer.android.com/reference/androidx/loader/content/Loader#startLoading()`. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/loader/content/Loader#onStopLoading()()` Subclasses must implement this to take care of stopping their loader, as per `https://developer.android.com/reference/androidx/loader/content/Loader#stopLoading()`. |

## Public constructors

### Loader

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
public Loader(@NonNull Context context)
```

Stores away the application context associated with context. Since Loaders can be used across multiple activities it's dangerous to store the context directly; always use `https://developer.android.com/reference/androidx/loader/content/Loader#getContext()` to retrieve the Loader's Context, don't use the constructor argument directly. The Context returned by `https://developer.android.com/reference/androidx/loader/content/Loader#getContext()` is safe to use across Activity instances.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | used to retrieve the application context. |

## Public methods

### abandon

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public void abandon()
```

This function will normally be called for you automatically by `https://developer.android.com/reference/androidx/loader/app/LoaderManager` when restarting a Loader. When using a Loader with `https://developer.android.com/reference/androidx/loader/app/LoaderManager`, you *must not* call this method yourself, or you will conflict with its management of the Loader. Tell the Loader that it is being abandoned. This is called prior to `https://developer.android.com/reference/androidx/loader/content/Loader#reset()` to have it retain its current data but not report any new data.

Must be called from the process's main thread.

### cancelLoad

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public boolean cancelLoad()
```

Attempt to cancel the current load task. Must be called on the main thread of the process.

Cancellation is not an immediate operation, since the load is performed in a background thread. If there is currently a load in progress, this method requests that the load be canceled, and notes this is the case; once the background thread has completed its work its remaining state will be cleared. If another load request comes in during this time, it will be held until the canceled load is complete.

| Returns |
|---|---|
| `boolean` | Returns false if the task could not be canceled, typically because it has already completed normally, or because `https://developer.android.com/reference/androidx/loader/content/Loader#startLoading()` hasn't been called; returns true otherwise. When true is returned, the task is still running and the `https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCanceledListener` will be called when the task completes. |

### commitContentChanged

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
public void commitContentChanged()
```

Commit that you have actually fully processed a content change that was returned by `https://developer.android.com/reference/androidx/loader/content/Loader#takeContentChanged()`. This is for use with `https://developer.android.com/reference/androidx/loader/content/Loader#rollbackContentChanged()` to handle situations where a load is cancelled. Call this when you have completely processed a load without it being cancelled.

### dataToString

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
public @NonNull String dataToString(@Nullable D data)
```

For debugging, converts an instance of the Loader's data class to a string that can be printed. Must handle a null data.

### deliverCancellation

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public void deliverCancellation()
```

Informs the registered `https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCanceledListener` that the load has been canceled. Should only be called by subclasses. Must be called from the process's main thread.

### deliverResult

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public void deliverResult(@Nullable D data)
```

Sends the result of the load to the registered listener. Should only be called by subclasses. Must be called from the process's main thread.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html D data` | the result of the load |

### dump

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0) Deprecated in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
public void [dump](https://developer.android.com/reference/androidx/loader/content/Loader#dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[]))(
    @NonNull String prefix,
    @Nullable FileDescriptor fd,
    @NonNull PrintWriter writer,
    @Nullable String[] args
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Consider using `https://developer.android.com/reference/androidx/loader/app/LoaderManager#enableDebugLogging(boolean)` to understand the series of operations performed by LoaderManager.

Print the Loader's state into the given stream.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html prefix` | Text to print at the front of each line. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/io/FileDescriptor.html fd` | The raw file descriptor that the dump is being sent to. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/io/PrintWriter.html writer` | A PrintWriter to which the dump is to be set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html String[] args` | Additional arguments to the dump request. |

### forceLoad

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public void forceLoad()
```

Force an asynchronous load. Unlike `https://developer.android.com/reference/androidx/loader/content/Loader#startLoading()` this will ignore a previously loaded data set and load a new one. This simply calls through to the implementation's `https://developer.android.com/reference/androidx/loader/content/Loader#onForceLoad()`. You generally should only call this when the loader is started -- that is, `https://developer.android.com/reference/androidx/loader/content/Loader#isStarted()` returns true.

Must be called from the process's main thread.

### getContext

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
public @NonNull Context getContext()
```

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html` | an application context retrieved from the Context passed to the constructor. |

### getId

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
public int getId()
```

| Returns |
|---|---|
| `int` | the ID of this loader |

### isAbandoned

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
public boolean isAbandoned()
```

Return whether this loader has been abandoned. In this state, the loader *must not* report any new data, and *must* keep its last reported data valid until it is finally reset.

### isReset

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
public boolean isReset()
```

Return whether this load has been reset. That is, either the loader has not yet been started for the first time, or its `https://developer.android.com/reference/androidx/loader/content/Loader#reset()` has been called.

### isStarted

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
public boolean isStarted()
```

Return whether this load has been started. That is, its `https://developer.android.com/reference/androidx/loader/content/Loader#startLoading()` has been called and no calls to `https://developer.android.com/reference/androidx/loader/content/Loader#stopLoading()` or `https://developer.android.com/reference/androidx/loader/content/Loader#reset()` have yet been made.

### onContentChanged

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public void onContentChanged()
```

Called when `https://developer.android.com/reference/androidx/loader/content/Loader.ForceLoadContentObserver` detects a change. The default implementation checks to see if the loader is currently started; if so, it simply calls `https://developer.android.com/reference/androidx/loader/content/Loader#forceLoad()`; otherwise, it sets a flag so that `https://developer.android.com/reference/androidx/loader/content/Loader#takeContentChanged()` returns true.

Must be called from the process's main thread.

### registerListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public void registerListener(
    int id,
    @NonNull Loader.OnLoadCompleteListener<D> listener
)
```

Registers a class that will receive callbacks when a load is complete. The callback will be called on the process's main thread so it's safe to pass the results to widgets.

Must be called from the process's main thread.

### registerOnLoadCanceledListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public void registerOnLoadCanceledListener(
    @NonNull Loader.OnLoadCanceledListener<D> listener
)
```

Registers a listener that will receive callbacks when a load is canceled. The callback will be called on the process's main thread so it's safe to pass the results to widgets. Must be called from the process's main thread.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCanceledListener<D> listener` | The listener to register. |

### reset

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public void reset()
```

This function will normally be called for you automatically by `https://developer.android.com/reference/androidx/loader/app/LoaderManager` when destroying a Loader. When using a Loader with `https://developer.android.com/reference/androidx/loader/app/LoaderManager`, you *must not* call this method yourself, or you will conflict with its management of the Loader. Resets the state of the Loader. The Loader should at this point free all of its resources, since it may never be called again; however, its `https://developer.android.com/reference/androidx/loader/content/Loader#startLoading()` may later be called at which point it must be able to start running again.

This updates the Loader's internal state so that `https://developer.android.com/reference/androidx/loader/content/Loader#isStarted()` and `https://developer.android.com/reference/androidx/loader/content/Loader#isReset()` will return the correct values, and then calls the implementation's `https://developer.android.com/reference/androidx/loader/content/Loader#onReset()`.

Must be called from the process's main thread.

### rollbackContentChanged

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
public void rollbackContentChanged()
```

Report that you have abandoned the processing of a content change that was returned by `https://developer.android.com/reference/androidx/loader/content/Loader#takeContentChanged()` and would like to rollback to the state where there is again a pending content change. This is to handle the case where a data load due to a content change has been canceled before its data was delivered back to the loader.

### startLoading

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public final void startLoading()
```

This function will normally be called for you automatically by `https://developer.android.com/reference/androidx/loader/app/LoaderManager` when the associated fragment/activity is being started. When using a Loader with `https://developer.android.com/reference/androidx/loader/app/LoaderManager`, you *must not* call this method yourself, or you will conflict with its management of the Loader. Starts an asynchronous load of the Loader's data. When the result is ready the callbacks will be called on the process's main thread. If a previous load has been completed and is still valid the result may be passed to the callbacks immediately. The loader will monitor the source of the data set and may deliver future callbacks if the source changes. Calling `https://developer.android.com/reference/androidx/loader/content/Loader#stopLoading()` will stop the delivery of callbacks.

This updates the Loader's internal state so that `https://developer.android.com/reference/androidx/loader/content/Loader#isStarted()` and `https://developer.android.com/reference/androidx/loader/content/Loader#isReset()` will return the correct values, and then calls the implementation's `https://developer.android.com/reference/androidx/loader/content/Loader#onStartLoading()`.

Must be called from the process's main thread.

### stopLoading

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public void stopLoading()
```

This function will normally be called for you automatically by `https://developer.android.com/reference/androidx/loader/app/LoaderManager` when the associated fragment/activity is being stopped. When using a Loader with `https://developer.android.com/reference/androidx/loader/app/LoaderManager`, you *must not* call this method yourself, or you will conflict with its management of the Loader.

Stops delivery of updates until the next time `https://developer.android.com/reference/androidx/loader/content/Loader#startLoading()` is called. Implementations should *not* invalidate their data at this point -- clients are still free to use the last data the loader reported. They will, however, typically stop reporting new data if the data changes; they can still monitor for changes, but must not report them to the client until and if `https://developer.android.com/reference/androidx/loader/content/Loader#startLoading()` is later called.

This updates the Loader's internal state so that `https://developer.android.com/reference/androidx/loader/content/Loader#isStarted()` will return the correct value, and then calls the implementation's `https://developer.android.com/reference/androidx/loader/content/Loader#onStopLoading()`.

Must be called from the process's main thread.

### takeContentChanged

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
public boolean takeContentChanged()
```

Take the current flag indicating whether the loader's content had changed while it was stopped. If it had, true is returned and the flag is cleared.

### toString

```
public @NonNull String toString()
```

### unregisterListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public void unregisterListener(@NonNull Loader.OnLoadCompleteListener<D> listener)
```

Remove a listener that was previously added with `https://developer.android.com/reference/androidx/loader/content/Loader#registerListener(int,androidx.loader.content.Loader.OnLoadCompleteListener<D>)`. Must be called from the process's main thread.

### unregisterOnLoadCanceledListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
public void unregisterOnLoadCanceledListener(
    @NonNull Loader.OnLoadCanceledListener<D> listener
)
```

Unregisters a listener that was previously added with `https://developer.android.com/reference/androidx/loader/content/Loader#registerOnLoadCanceledListener(androidx.loader.content.Loader.OnLoadCanceledListener<D>)`. Must be called from the process's main thread.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCanceledListener<D> listener` | The listener to unregister. |

## Protected methods

### onAbandon

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
protected void onAbandon()
```

Subclasses implement this to take care of being abandoned. This is an optional intermediate state prior to `https://developer.android.com/reference/androidx/loader/content/Loader#onReset()` -- it means that the client is no longer interested in any new data from the loader, so the loader must not report any further updates. However, the loader *must* keep its last reported data valid until the final `https://developer.android.com/reference/androidx/loader/content/Loader#onReset()` happens. You can retrieve the current abandoned state with `https://developer.android.com/reference/androidx/loader/content/Loader#isAbandoned()`. This will always be called from the process's main thread.

### onCancelLoad

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
protected boolean onCancelLoad()
```

Subclasses must implement this to take care of requests to `https://developer.android.com/reference/androidx/loader/content/Loader#cancelLoad()`. This will always be called from the process's main thread.

| Returns |
|---|---|
| `boolean` | Returns false if the task could not be canceled, typically because it has already completed normally, or because `https://developer.android.com/reference/androidx/loader/content/Loader#startLoading()` hasn't been called; returns true otherwise. When true is returned, the task is still running and the `https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCanceledListener` will be called when the task completes. |

### onForceLoad

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
protected void onForceLoad()
```

Subclasses must implement this to take care of requests to `https://developer.android.com/reference/androidx/loader/content/Loader#forceLoad()`. This will always be called from the process's main thread.

### onReset

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
protected void onReset()
```

Subclasses must implement this to take care of resetting their loader, as per `https://developer.android.com/reference/androidx/loader/content/Loader#reset()`. This is not called by clients directly, but as a result of a call to `https://developer.android.com/reference/androidx/loader/content/Loader#reset()`. This will always be called from the process's main thread.

### onStartLoading

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
protected void onStartLoading()
```

Subclasses must implement this to take care of loading their data, as per `https://developer.android.com/reference/androidx/loader/content/Loader#startLoading()`. This is not called by clients directly, but as a result of a call to `https://developer.android.com/reference/androidx/loader/content/Loader#startLoading()`. This will always be called from the process's main thread.

### onStopLoading

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/loader#1.0.0)

```
@MainThread
protected void onStopLoading()
```

Subclasses must implement this to take care of stopping their loader, as per `https://developer.android.com/reference/androidx/loader/content/Loader#stopLoading()`. This is not called by clients directly, but as a result of a call to `https://developer.android.com/reference/androidx/loader/content/Loader#stopLoading()`. This will always be called from the process's main thread.