目录

Public Method Summary

Return typeMethod name
booleanisComplete()
Checks whether the task is completed. Returns true if the task is completed; false otherwise.
booleanisSuccessful()
Checks whether the task is completed successfully. Returns true if the task is completed successfully; false otherwise.
booleanisCanceled()
Checks whether the task is canceled. Returns true if the task is canceled; false otherwise.
TResultgetResult()
Gets the result of the task if it is completed.
< E extends Throwable > TResultgetResult(Class exceptionClass) throws E
Gets the result of the task if it is completed. If an exception occurs and belongs to the exception class specified in the parameters, the specified exception class will be returned.
ExceptiongetException()
Returns the exception that causes the task to fail.
Task< TResult >addOnSuccessListener(OnSuccessListener< TResult > listener)
Adds one or more listeners. If only one listener is added, it will be called following successful completion of the task. If multiple listeners are added, they will be called in the order in which they were added. The listener(s) will be called on the main thread.
Task< TResult >addOnSuccessListener(Executor executor,OnSuccessListener< TResult > listener)
Adds one or more listeners. If only one listener is added, it will be called following successful completion of the task. If multiple listeners are added, they will be called in the order in which they were added. The listener(s) will be called in the specified executor.
Task< TResult >addOnFailureListener(OnFailureListener listener)
Adds one or more listeners that will be called on the main thread following the task failure. If multiple listeners are added, they will be called in the order in which they were added.
Task< TResult >addOnFailureListener(Executor executor,OnFailureListener listener)
Adds one or more listeners that will be called following the task failure. If multiple listeners are added, they will be called in the order in which they were added. The listener(s) will be called in the specified executor.
Task< TResult >addOnCompleteListener(OnCompleteListener < TResult > listener)
Adds one or more listeners. If only one listener is added, it will be called on the main thread following task completion. If multiple listeners are added, they will be called in the order in which they were added.
Task< TResult >addOnCompleteListener(Executor executor, OnCompleteListener< TResult > listener)
Adds one or more listeners. If only one listener is added, it will be called following task completion. If multiple listeners are added, they will be called in the order in which they were added. The listener(s) will be called in the specified executor.
Task< TResult >addOnCanceledListener(OnCanceledListener listener)
Adds one or more listeners. If only one listener is added, it will be called on the main thread following task cancellation. If multiple listeners are added, they will be called in the order in which they were added.
Task< TResult >addOnCanceledListener(Executor executor, OnCanceledListener listener)
Adds one or more listeners. If only one listener is added, it will be called following task cancellation. If multiple listeners are added, they will be called in the order in which they were added. The listener(s) will be called in the specified executor.
< TContinuationResult > Task< TContinuationResult >onSuccessTask(SuccessContinuation< TResult, TContinuationResult > listener)
After Task< TResult>is successfully executed, execute the then method to call the listener. The method returns a Task< TContinuationResult>value. Creates a new Task< TContinuationResult>task based on the returned Task< TContinuationResult >value. The listener is executed on the main thread.
If the current task is canceled, the new task is also canceled and the listener is not executed. If the current task fails, corresponding processing will be performed and the listener will not be executed.
< TContinuationResult > Task< TContinuationResult >onSuccessTask(Executor executor,SuccessContinuation< TResult, TContinuationResult > listener)
After Task< TResult>is successfully executed, execute the then method to call the listener. The method returns a Task< TContinuationResult>value. Creates a new Task< TContinuationResult>task based on the returned Task< TContinuationResult >value. The listener is executed on the main thread.
If the current task is canceled, the new task is also canceled and the listener is not executed. If the current task fails, corresponding processing will be performed and the listener will not be executed.
< TContinuationResult > Task< TContinuationResult >continueWithTask(Continuation< TResult, Task< TContinuationResult >> taskContinuation)
After Task< TResult>is successfully executed, execute the then method to call the listerner. The method returns a Task< TContinuationResult> value. Creates a new Task< TContinuationResult>task based on the returned Task< TContinuationResult >value. The listener is executed in the specified executor.
If the current task is canceled, the new task is also canceled and the listener is not executed. If the current task fails, corresponding processing will be performed and the listener will not be executed.
< TContinuationResult > Task< TContinuationResult >continueWithTask(Executor executor,Continuation< TResult, Task< TContinuationResult >> taskContinuation)
After Task< TResult>is successfully executed, execute the then method to call the listerner. The method returns a Task< TContinuationResult> value. Creates a new Task< TContinuationResult>task based on the returned Task< TContinuationResult >value. The listener is executed on the main thread.
If the current task is canceled, the returned taskContinuation will still be executed.
< TContinuationResult > Task< TContinuationResult >continueWith(Continuation< TResult, TContinuationResult > continuation)
After Task< TResult>is successfully executed, execute the then method to call the listerner. The method returns a Task< TContinuationResult>value. Creates a new Task< TContinuationResult>task based on the returned Task< TContinuationResult >value. The listener is executed on the main thread.
If the current task is canceled, the returned taskContinuation will not be executed.
< TContinuationResult > Task< TContinuationResult >continueWith(final Executor executor, final Continuation< TResult, TContinuationResult > continuation)
After Task< TResult>is successfully executed, execute the then method to call the listerner. The method returns a Task< TContinuationResult>value. Creates a new Task< TContinuationResult>task based on the returned Task< TContinuationResult >value. The listener is executed in the executor.
If the current task is canceled, the returned taskContinuation will not be executed.

Public Methods

Method
public abstract boolean isComplete()
Checks whether the task is completed. Returns true if the task is completed; false otherwise.

Return

typedesc
booleanReturns true if the task is completed; false otherwise.
Method
public abstract boolean isSuccessful()
Checks whether the task is completed successfully. Returns true if the task is completed successfully; false otherwise.

Return

typedesc
booleanReturns true if the task is completed successfully; false otherwise.
Method
public abstract boolean isCanceled()
Checks whether the task is canceled. Returns true if the task is canceled; false otherwise.

Return

typedesc
booleanReturns true if the task is canceled; false otherwise.
Method
public abstract TResult getResult()
Gets the result of the task if it is completed.

Return

typedesc
TResultResult of the task.
Method
public abstract < E extends Throwable > TResult getResult(Class< E > exceptionClass) throws E
Gets the result of the task if it is completed. If an exception occurs and belongs to the exception class specified in the parameters, the specified exception class will be returned.

Parameters

Parameter nameParameter desc
exceptionClassSpecified exception class.

Throws
Parameter nameParameter desc
Class< E >Throws the specified exception class.
RuntimeExceptionRuntimeException returned if the task fails with an exception that does not fall into the class in the input parameter.

Return
typedesc
TResultResult of the task.
Method
public abstract Exception getException()
Returns the exception that causes the task to fail.

Return

typedesc
ExceptionException that causes the task to fail.
Method
public abstract Task< TResult > addOnSuccessListener(OnSuccessListener< TResult > listener)
Adds one or more listeners. If only one listener is added, it will be called following successful completion of the task. If multiple listeners are added, they will be called in the order in which they were added. The listener(s) will be called on the main thread.

Parameters

Parameter nameParameter desc
listenerListener, which is called back after a task is successfully completed.

Return
typedesc
TaskResult of the task.
Method
public abstract Task< TResult > addOnSuccessListener(Executor executor,OnSuccessListener< TResult > listener)
Adds one or more listeners. If only one listener is added, it will be called following successful completion of the task. If multiple listeners are added, they will be called in the order in which they were added. The listener(s) will be called in the specified executor.

Parameters

Parameter nameParameter desc
executorExecutor to use to call back the listener.
listenerListener, which is called back after a task is successfully completed.

Return
typedesc
Task< TResult >Result of the task.
Method
public abstract Task< TResult > addOnFailureListener(OnFailureListener listener)
Adds one or more listeners that will be called on the main thread following the task failure. If multiple listeners are added, they will be called in the order in which they were added.

Parameters

Parameter nameParameter desc
listenerListener, which is called back after a task fails.

Return
typedesc
Task< TResult >Result of the task.
Method
public abstract Task< TResult > addOnFailureListener(Executor executor,OnFailureListener listener)
Adds one or more listeners that will be called following the task failure. If multiple listeners are added, they will be called in the order in which they were added. The listener(s) will be called in the specified executor.

Parameters

Parameter nameParameter desc
executorExecutor to use to call back the listener.
listenerListener, which is called back after a task fails.

Return
typedesc
Task< TResult >Result of the task.
Method
public Task< TResult > addOnCompleteListener(OnCompleteListener < TResult > listener)
Adds one or more listeners. If only one listener is added, it will be called on the main thread following task completion. If multiple listeners are added, they will be called in the order in which they were added.

Parameters

Parameter nameParameter desc
listenerListener, which is called back after task completion.

Return
typedesc
Task< TResult >Result of the task.
Method
public Task< TResult > addOnCompleteListener(Executor executor, OnCompleteListener< TResult > listener)
Adds one or more listeners. If only one listener is added, it will be called following task completion. If multiple listeners are added, they will be called in the order in which they were added. The listener(s) will be called in the specified executor.

Parameters

Parameter nameParameter desc
executorExecutor to use to call back the listener.
listenerListener, which is called back after task completion.

Return
typedesc
Task< TResult >Result of the task.
Method
public Task< TResult > addOnCanceledListener(OnCanceledListener listener)
Adds one or more listeners. If only one listener is added, it will be called on the main thread following task cancellation. If multiple listeners are added, they will be called in the order in which they were added.

Parameters

Parameter nameParameter desc
listenerListener, which is called back after a task is canceled.

Return
typedesc
Task< TResult >Result of the task.
Method
public Task< TResult > addOnCanceledListener(Executor executor, OnCanceledListener listener)
Adds one or more listeners. If only one listener is added, it will be called following task cancellation. If multiple listeners are added, they will be called in the order in which they were added. The listener(s) will be called in the specified executor.

Parameters

Parameter nameParameter desc
executorExecutor to use to call back the listener.
listenerListener, which is called back after a task is canceled.

Return
typedesc
Task< TResult >Result of the task.
Method
public < TContinuationResult > Task< TContinuationResult > onSuccessTask(SuccessContinuation< TResult, TContinuationResult > listener)
After Task< TResult >is successfully executed, execute the then method to call the listener. The method returns a Task< TContinuationResult >value. Creates a new Task< TContinuationResult >task based on the returned Task< TContinuationResult >value. The listener is executed on the main thread.
If the current task is canceled, the new task is also canceled and the listener is not executed. If the current task fails, corresponding processing will be performed and the listener will not be executed.

Parameters

Parameter nameParameter desc
listenerAPI implementation instance, which implements the then API and is used to call the subsequent task after the current task is successfully completed.

Return
typedesc
Task< TContinuationResult >Task subsequent to the current task.
Method
public < TContinuationResult > Task< TContinuationResult > onSuccessTask(Executor executor,SuccessContinuation< TResult, TContinuationResult > listener)
After Task< TResult >is successfully executed, execute the then method to call the listerner. The method returns a Task< TContinuationResult > value. Creates a new Task< TContinuationResult >task based on the returned Task< TContinuationResult >value. The listener is executed in the specified executor.
If the current task is canceled, the new task is also canceled and the listener is not executed. If the current task fails, corresponding processing will be performed and the listener will not be executed.

Parameters

Parameter nameParameter desc
executorExecutor to use to execute the listener.
listenerAPI implementation instance, which implements the then API and is used to call the subsequent task after the current task is successfully completed.

Return
typedesc
Task< TContinuationResult >Task subsequent to the current task.
Method
public < TContinuationResult > Task< TContinuationResult > continueWithTask(Continuation< TResult, Task< TContinuationResult >> taskContinuation)
After Task< TResult >is successfully executed, execute the then method to call the listerner. The method returns a Task< TContinuationResult > value. Creates a new Task< TContinuationResult >task based on the returned Task< TContinuationResult >value. The listener is executed on the main thread.
If the current task is canceled, the returned taskContinuation will still be executed.

Parameters

Parameter nameParameter desc
executorExecutor to use to execute taskContinuation.
taskContinuationAPI implementation instance, which implements the then API and is used to call the subsequent task after the current task is successfully completed.

Return
typedesc
Task< TContinuationResult >Task subsequent to the current task.
Method
public < TContinuationResult > Task< TContinuationResult > continueWithTask(Executor executor,Continuation< TResult, Task< TContinuationResult >> taskContinuation)
After Task< TResult >is successfully executed, execute the then method to call the listerner. The method returns a Task< TContinuationResult >value. Creates a new Task< TContinuationResult >task based on the returned Task< TContinuationResult >value. The listener is executed in the executor.
If the current task is canceled, the returned taskContinuation will still be executed.

Parameters

Parameter nameParameter desc
executorExecutor to use to execute taskContinuation.
taskContinuationAPI implementation instance, which implements the then API and is used to call the subsequent task after the current task is successfully completed.

Return
typedesc
Task< TContinuationResult >Task subsequent to the current task.
Method
public < TContinuationResult > Task< TContinuationResult > continueWith(final Executor executor, final Continuation< TResult, TContinuationResult > continuation)
After Task< TResult >is successfully executed, execute the then method to call the listerner. The method returns a Task< TContinuationResult >value. Creates a new Task< TContinuationResult >task based on the returned Task< TContinuationResult >value. The listener is executed on the main thread.
If the current task is canceled, the returned taskContinuation will not be executed.

Parameters

Parameter nameParameter desc
executorExecutor to use to execute the specified continuation.
taskContinuationAPI implementation instance, which implements the then API and is used to call the subsequent task after the current task is successfully completed.

Return
typedesc
Task< TContinuationResult >Task subsequent to the current task.
Method
public void destroy()
Destroy the PublisherAdView. This method should be called in the parent Activity’s onDestroy() method. No other methods should be called on the PublisherAdView after destroy() is called.