belongs to Maven artifact com.android.support:loader:28.0.0-alpha1
LoaderManager
  public
  
  
  abstract
  class
  LoaderManager
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.support.v4.app.LoaderManager | 
Static library support version of the framework's 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 FragmentActivity to use this.
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        interface | LoaderManager.LoaderCallbacks<D>Callback interface for a client to interact with the manager. | 
| Public constructors | |
|---|---|
| 
      LoaderManager()
       | |
| Public methods | |
|---|---|
| 
        abstract
        
        
        
        
        void | 
      destroyLoader(int id)
      Stops and removes the loader with the given ID. | 
| 
        abstract
        
        
        
        
        void | 
      dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
      Print the LoaderManager's state into the given stream. | 
| 
        
        
        static
        
        
        void | 
      enableDebugLogging(boolean enabled)
      Control whether the framework's internal loader manager debugging logs are turned on. | 
| 
        
        
        static
        
        <T extends LifecycleOwner & ViewModelStoreOwner>
        LoaderManager | 
      getInstance(T owner)
      Gets a LoaderManager associated with the given owner, such as a  | 
| 
        abstract
        
        
        
        <D>
        Loader<D> | 
      getLoader(int id)
      Return the Loader with the given id or null if no matching Loader is found. | 
| 
        
        
        
        
        
        boolean | 
      hasRunningLoaders()
      Returns true if any loaders managed are currently running and have not returned data to the application yet. | 
| 
        abstract
        
        
        
        <D>
        Loader<D> | 
      initLoader(int id, Bundle args, LoaderCallbacks<D> callback)
      Ensures a loader is initialized and active. | 
| 
        abstract
        
        
        
        
        void | 
      markForRedelivery()
      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
        
        
        
        <D>
        Loader<D> | 
      restartLoader(int id, Bundle args, LoaderCallbacks<D> callback)
      Starts a new or restarts an existing  | 
| Inherited methods | |
|---|---|
|  From
class 
  
    java.lang.Object
  
 | |
Public constructors
Public methods
destroyLoader
void destroyLoader (int id)
Stops and removes the loader with the given ID.  If this loader
 had previously reported data to the client through
 onLoadFinished(Loader, Object), a call
 will be made to onLoaderReset(Loader).
 
Must be called from the process's main thread.
| Parameters | |
|---|---|
| id | int | 
dump
void dump (String prefix, 
                FileDescriptor fd, 
                PrintWriter writer, 
                String[] args)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 | String: Additional arguments to the dump request. | 
enableDebugLogging
void enableDebugLogging (boolean enabled)
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.
| Parameters | |
|---|---|
| enabled | boolean | 
getInstance
LoaderManager getInstance (T owner)
Gets a LoaderManager associated with the given owner, such as a FragmentActivity or
 Fragment.
| Parameters | |
|---|---|
| owner | T: The owner that should be used to create the returned LoaderManager | 
| Returns | |
|---|---|
| LoaderManager | A valid LoaderManager | 
getLoader
Loader<D> getLoader (int id)
Return the Loader with the given id or null if no matching Loader is found.
| Parameters | |
|---|---|
| id | int | 
| Returns | |
|---|---|
| Loader<D> | |
hasRunningLoaders
boolean hasRunningLoaders ()
Returns true if any loaders managed are currently running and have not returned data to the application yet.
| Returns | |
|---|---|
| boolean | |
initLoader
Loader<D> initLoader (int id, Bundle args, LoaderCallbacks<D> callback)
Ensures a loader is initialized and active. If the loader doesn't already exist, one is created and (if the activity/fragment is currently started) starts the loader. Otherwise the last created loader is re-used.
In either case, the given callback is associated with the loader, and
 will be called as the loader state changes.  If at the point of call
 the caller is in its started state, and the requested loader
 already exists and has generated its data, then
 callback onLoadFinished(Loader will
 be called immediately (inside of this function), so you must be prepared
 for this to happen.
 
Must be called from the process's main thread.
| Parameters | |
|---|---|
| id | int: A unique identifier for this loader.  Can be whatever you want.
 Identifiers are scoped to a particular LoaderManager instance. | 
| args | Bundle: Optional arguments to supply to the loader at construction.
 If a loader already exists (a new one does not need to be created), this
 parameter will be ignored and the last arguments continue to be used. | 
| callback | LoaderCallbacks: Interface the LoaderManager will call to report about
 changes in the state of the loader.  Required. | 
| Returns | |
|---|---|
| Loader<D> | |
markForRedelivery
void markForRedelivery ()
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.
 In cases where no data has yet been delivered, this is effectively a no-op. In cases where
 data has already been delivered via onLoadFinished(Loader, Object),
 this will ensure that onLoadFinished(Loader, Object) is called again
 with the same data.
 
 Call this only if you are implementing a LifecycleOwner where the views/elements that
 developers are likely to use in onLoadFinished(Loader, Object) can be
 created and destroyed multiple times without the LifecycleOwner itself being
 destroyed. Call this when the views/elements are being destroyed to ensure that the data
 is redelivered upon recreation.
restartLoader
Loader<D> restartLoader (int id, Bundle args, LoaderCallbacks<D> callback)
Starts a new or restarts an existing Loader in
 this manager, registers the callbacks to it,
 and (if the activity/fragment is currently started) starts loading it.
 If a loader with the same id has previously been
 started it will automatically be destroyed when the new loader completes
 its work. The callback will be delivered before the old loader
 is destroyed.
 
Must be called from the process's main thread.
| Parameters | |
|---|---|
| id | int: A unique identifier for this loader.  Can be whatever you want.
 Identifiers are scoped to a particular LoaderManager instance. | 
| args | Bundle: Optional arguments to supply to the loader at construction. | 
| callback | LoaderCallbacks: Interface the LoaderManager will call to report about
 changes in the state of the loader.  Required. | 
| Returns | |
|---|---|
| Loader<D> | |
- Annotations
- Interfaces- ActionBarDrawerToggle.Delegate
- ActionBarDrawerToggle.DelegateProvider
- ActivityCompat.OnRequestPermissionsResultCallback
- ActivityCompat.PermissionCompatDelegate
- FragmentManager.BackStackEntry
- FragmentManager.OnBackStackChangedListener
- LoaderManager.LoaderCallbacks
- NotificationCompat.Action.Extender
- NotificationCompat.Extender
- SharedElementCallback.OnSharedElementsReadyListener
- TaskStackBuilder.SupportParentable
 
- Classes- ActionBarDrawerToggle
- ActivityCompat
- ActivityManagerCompat
- ActivityOptionsCompat
- AlarmManagerCompat
- AppLaunchChecker
- AppOpsManagerCompat
- BundleCompat
- DialogFragment
- Fragment
- Fragment.SavedState
- FragmentActivity
- FragmentContainer
- FragmentController
- FragmentHostCallback
- FragmentManager
- FragmentManager.FragmentLifecycleCallbacks
- FragmentManagerNonConfig
- FragmentPagerAdapter
- FragmentStatePagerAdapter
- FragmentTabHost
- FragmentTransaction
- FrameMetricsAggregator
- JobIntentService
- ListFragment
- LoaderManager
- NavUtils
- NotificationCompat
- NotificationCompat.Action
- NotificationCompat.Action.Builder
- NotificationCompat.Action.WearableExtender
- NotificationCompat.BigPictureStyle
- NotificationCompat.BigTextStyle
- NotificationCompat.Builder
- NotificationCompat.CarExtender
- NotificationCompat.CarExtender.UnreadConversation
- NotificationCompat.CarExtender.UnreadConversation.Builder
- NotificationCompat.DecoratedCustomViewStyle
- NotificationCompat.InboxStyle
- NotificationCompat.MessagingStyle
- NotificationCompat.MessagingStyle.Message
- NotificationCompat.Style
- NotificationCompat.WearableExtender
- NotificationCompatExtras
- NotificationCompatSideChannelService
- NotificationManagerCompat
- RemoteInput
- RemoteInput.Builder
- ServiceCompat
- ShareCompat
- ShareCompat.IntentBuilder
- ShareCompat.IntentReader
- SharedElementCallback
- TaskStackBuilder
 
- Exceptions
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
