加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20110501020513/http://developer.android.com:80/reference/android/content/AsyncTaskLoader.html
public abstract class

AsyncTaskLoader

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

Class Overview

Abstract Loader that provides an AsyncTask to do the work.

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.content.Loader
From class java.lang.Object

Public Constructors

public AsyncTaskLoader (Context context)

Since: API Level 11

Public Methods

public boolean cancelLoad ()

Since: API Level 11

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)

Since: API Level 11

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 ()

Since: API Level 11

public void onCanceled (D data)

Since: API Level 11

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)

Since: API Level 11

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 ()

Since: API Level 11

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 ()

Since: API Level 11

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.