to top
Android APIs
public abstract class

AsyncTaskLoader

extends Loader<D>
java.lang.Object
   ↳ android.support.v4.content.Loader<D>
     ↳ android.support.v4.content.AsyncTaskLoader<D>
Known Direct Subclasses

Class Overview

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

Public Constructors
AsyncTaskLoader(Context context)
Public Methods
boolean cancelLoad()
Attempt to cancel the current load task.
void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
Print the Loader's state into the given stream.
abstract D loadInBackground()
void onCanceled(D data)
Called if the task was canceled before it was completed.
void setUpdateThrottle(long delayMS)
Set amount to throttle updates by.
Protected Methods
void onForceLoad()
Subclasses must implement this to take care of requests to forceLoad().
D onLoadInBackground()
Called on a worker thread to perform the actual load.
[Expand]
Inherited Methods
From class android.support.v4.content.Loader
From class java.lang.Object

Public Constructors

public AsyncTaskLoader (Context context)

Public Methods

public boolean cancelLoad ()

Attempt to cancel the current load task. See cancel(boolean) for more info. Must be called on the main thread of the process.

Cancelling 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 cancelled, 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 cancelled load is complete.

Returns
  • Returns false if the task could not be cancelled, typically because it has already completed normally, or because startLoading() hasn't been called; returns true otherwise.

public void dump (String prefix, FileDescriptor fd, PrintWriter writer, String[] args)

Print the Loader's state into the given stream.

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

public abstract D loadInBackground ()

public void onCanceled (D data)

Called if the task was canceled before it was completed. Gives the class a chance to properly dispose of the result.

public void setUpdateThrottle (long delayMS)

Set amount to throttle updates by. This is the minimum time from when the last onLoadInBackground() call has completed until a new load is scheduled.

Parameters
delayMS Amount of delay, in milliseconds.

Protected Methods

protected void onForceLoad ()

Subclasses must implement this to take care of requests to forceLoad(). This will always be called from the process's main thread.

protected D onLoadInBackground ()

Called on a worker thread to perform the actual load. Implementations should not deliver the result directly, but should return them from this method, which will eventually end up calling deliverResult(D) on the UI thread. If implementations need to process the results on the UI thread they may override deliverResult(D) and do so there.

Returns
  • Implementations must return the result of their load operation.