Android 12 Developer Preview is here! Try it out, and give us your feedback!

LoaderManager

abstract class LoaderManager
kotlin.Any
   ↳ androidx.loader.app.LoaderManager

Static library support version of the framework's android.app.LoaderManager. 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.

Your activity must derive from androidx.fragment.app.FragmentActivity to use this.

Summary

Nested classes
abstract

Callback interface for a client to interact with the manager.

Public constructors

Static library support version of the framework's android.app.LoaderManager.

Public methods
abstract Unit

Stops and removes the loader with the given ID.

abstract Unit
dump(prefix: String!, fd: FileDescriptor!, writer: PrintWriter!, args: Array<String!>!)

Print the LoaderManager's state into the given stream.

open static Unit

Control whether the framework's internal loader manager debugging logs are turned on.

open static LoaderManager
getInstance(@NonNull owner: T)

Gets a LoaderManager associated with the given owner, such as a androidx.fragment.app.FragmentActivity or androidx.fragment.app.Fragment.

abstract Loader<D>?

Return the Loader with the given id or null if no matching Loader is found.

open Boolean

Returns true if any loaders managed are currently running and have not returned data to the application yet.

abstract Loader<D>
initLoader(id: Int, @Nullable args: Bundle?, @NonNull callback: LoaderManager.LoaderCallbacks<D>)

Ensures a loader is initialized and active.

abstract Unit

Mark all Loaders associated with this LoaderManager for redelivery of their current data (if any), waiting for the next time the Loader is started if it is currently stopped.

abstract Loader<D>
restartLoader(id: Int, @Nullable args: Bundle?, @NonNull callback: LoaderManager.LoaderCallbacks<D>)

Starts a new or restarts an existing android.content.Loader in this manager, registers the callbacks to it, and (if the activity/fragment is currently started) starts loading it.

Public constructors

<init>

LoaderManager()

Static library support version of the framework's android.app.LoaderManager. 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.

Your activity must derive from androidx.fragment.app.FragmentActivity to use this.

Public methods

destroyLoader

@MainThread abstract fun destroyLoader(id: Int): Unit

Stops and removes the loader with the given ID. If this loader had previously reported data to the client through LoaderCallbacks#onLoadFinished(Loader, Object), a call will be made to LoaderCallbacks#onLoaderReset(Loader).

Must be called from the process's main thread.

dump

abstract fun dump(
    prefix: String!,
    fd: FileDescriptor!,
    writer: PrintWriter!,
    args: Array<String!>!
): Unit

Deprecated: Use enableDebugLogging(boolean) to understand the series of operations performed by LoaderManager.

Print the LoaderManager's state into the given stream.

Parameters
prefix String!: Text to print at the front of each line.
fd FileDescriptor!: The raw file descriptor that the dump is being sent to.
writer PrintWriter!: A PrintWriter to which the dump is to be set.
args Array<String!>!: Additional arguments to the dump request.

enableDebugLogging

open static fun enableDebugLogging(enabled: Boolean): Unit

Control whether the framework's internal loader manager debugging logs are turned on. If enabled, you will see output in logcat as the framework performs loader operations.

getInstance

@NonNull open static fun <T> getInstance(@NonNull owner: T): LoaderManager where T : LifecycleOwner!, T : ViewModelStoreOwner