We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
Referencescom.huawei.hmf.tasksClass SummaryTask<TResult>

Task<TResult>

Expand

Class Info

public abstract class Task<TResult>

A basic class of a task.

Public Method Summary

Expand

Qualifier and Type

Method Name and Description

boolean

isComplete()

Checks whether a task is completed. The true value is returned if a task is completed; false otherwise.

boolean

isSuccessful()

Checks whether a task is executed successfully. The true value is returned if a task is executed successfully; false otherwise.

boolean

isCanceled()

Checks whether a task is canceled. The true value is returned if a task is canceled; false otherwise.

TResult

getResult()

Obtains the execution result of a task if it is completed.

<E extends Throwable> TResult

getResultThrowException(Class<E> exceptionClass) throws E

Obtains the execution result of a task if it is completed. If an exception occurs and is specified by exceptionClass, the exception will be returned.

Exception

getException()

Obtains the exception that causes the task execution failure.

Task<TResult>

addOnSuccessListener(OnSuccessListener<TResult> listener)

Adds one or more listeners that will be called in the main thread when a task is successfully executed. Multiple listeners added will be called in the order in which they were added.

Task<TResult>

addOnSuccessListener(Executor executor,OnSuccessListener<TResult> listener)

Adds one or more listeners that will be called in a specified executor when a task is successfully executed. Multiple listeners added will be called in the order in which they were added.

Task<TResult>

addOnFailureListener(OnFailureListener listener)

Adds one or more listeners that will be called in the main thread upon the task execution failure. Multiple listeners added 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 in a specified executor upon the task execution failure. Multiple listeners added will be called in the order in which they were added.

Task<TResult>

addOnCompleteListener(OnCompleteListener<TResult> listener)

Adds one or more listeners that will be called in the main thread upon task completion. Multiple listeners added will be called in the order in which they were added.

Task<TResult>

addOnCompleteListener(Executor executor, OnCompleteListener<TResult> listener)

Adds one or more listeners that will be called in a specified executor upon task completion. Multiple listeners added will be called in the order in which they were added.

Task<TResult>

addOnCanceledListener(Activity activity, OnCanceledListener listener)

Adds one or more listeners that will be called in a specified executor upon task cancellation. Multiple listeners added will be called in the order in which they were added.

Task<TResult>

addOnCanceledListener(OnCanceledListener listener)

Adds one or more listeners that will be called in the main thread upon task cancellation. Multiple listeners added will be called in the order in which they were added.

Task<TResult>

addOnCanceledListener(Executor executor, OnCanceledListener listener)

Adds one or more listeners that will be called in a specified executor upon task cancellation. Multiple listeners added will be called in the order in which they were added.

<TContinuationResult> Task<TContinuationResult>

onSuccessTask(SuccessContinuation<TResult, TContinuationResult> listener)

A then method to call the listener after Task<TResult> is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in 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 to be executed, the failure handling will be performed and the listener will not be executed.

<TContinuationResult> Task<TContinuationResult>

onSuccessTask(Executor executor, SuccessContinuation<TResult, TContinuationResult> listener)

A then method to call the listener after Task<TResult> is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in a 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 to be executed, the failure handling will be performed and the listener will not be executed.

<TContinuationResult> Task<TContinuationResult>

continueWithTask(Continuation<TResult, Task<TContinuationResult>> taskContinuation)

A then method to call the listener after Task<TResult> is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in the main thread.

If the current task is canceled, returned taskContinuation will still be executed.

<TContinuationResult > Task<TContinuationResult>

continueWithTask(Executor executor, Continuation<TResult, Task<TContinuationResult>> taskContinuation)

A then method to call the listener after Task<TResult> is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in a specified executor.

If the current task is canceled, returned taskContinuation will still be executed.

<TContinuationResult> Task<TContinuationResult>

continueWith(Continuation<TResult, TContinuationResult> taskContinuation)

A then method to call the listener after Task is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in the main thread.

If the current task is canceled, returned taskContinuation will not be executed.

<TContinuationResult> Task<TContinuationResult>

continueWith( Executor executor, lContinuation<TResult, TContinuationResult> continuation)

A then method to call the listener after Task<TResult> is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in a specified executor.

If the current task is canceled, returned taskContinuation will not be executed.

Public Methods

isComplete

Expand

Method

public abstract boolean isComplete()

Checks whether a task is completed. The true value is returned if a task is completed; false otherwise.

Returns

Expand

Type

Description

boolean

true if the task is completed; false otherwise.

isSuccessful

Expand

Method

public abstract boolean isSuccessful()

Checks whether a task is executed successfully. The true value is returned if a task is executed successfully; false otherwise.

Returns

Expand

Type

Description

boolean

true if the task is executed successfully; false otherwise.

isCanceled

Expand

Method

public abstract boolean isCanceled()

Checks whether a task is canceled. The true value is returned if a task is canceled; false otherwise.

Returns

Expand

Type

Description

boolean

true if the task is canceled; false otherwise.

getResult

Expand

Method

public abstract TResult getResult()

Obtains the execution result of a task if it is completed.

Returns

Expand

Type

Description

TResult

A task execution result.

getResultThrowException

Expand

Method

public abstract <E extends Throwable> TResult getResultThrowException(Class<E> exceptionClass) throws E

Obtains the execution result of a task if it is completed. If an exception occurs and is specified by exceptionClass, the exception will be returned.

Parameters

Expand

Name

Type

Constraint

Description

exceptionClass

Class<E>

Y

Exception type.

Throws

Expand

Name

Description

Class<E>

If an exception is specified by exceptionClass.

RuntimeException

If a task fails to be executed but an exception is not specified by exceptionClass.

Returns

Expand

Type

Description

TResult

A task execution result.

getException

Expand

Method

public abstract Exception getException()

Obtains the exception that causes the task execution failure.

Returns

Expand

Type

Description

Exception

An exception that causes the task execution failure.

addOnSuccessListener(OnSuccessListener<TResult> listener)

Expand

Method

public abstract Task<TResult> addOnSuccessListener(OnSuccessListener<TResult> listener)

Adds one or more listeners that will be called in the main thread when a task is successfully executed. Multiple listeners added will be called in the order in which they were added.

Parameters

Expand

Name

Type

Constraint

Description

listener

OnSuccessListener<TResult>

Y

Listener, which is called back when a task is executed successfully.

Returns

Expand

Type

Description

Task

A task execution result.

addOnSuccessListener(Executor executor, OnSuccessListener<TResult> listener)

Expand

Method

public abstract Task<TResult> addOnSuccessListener(Executor executor, OnSuccessListener<TResult> listener)

Adds one or more listeners that will be called in a specified executor when a task is successfully executed. Multiple listeners added will be called in the order in which they were added.

Parameters

Expand

Name

Type

Constraint

Description

executor

Executor

Y

Executor used for callback.

listener

OnSuccessListener<TResult>

Y

Listener, which is called back when a task is executed successfully.

Returns

Expand

Type

Description

Task<TResult>

A task execution result.

addOnFailureListener(OnFailureListener listener)

Expand

Method

public abstract Task<TResult> addOnFailureListener(OnFailureListener listener)

Adds one or more listeners that will be called in the main thread upon the task execution failure. Multiple listeners added will be called in the order in which they were added.

Parameters

Expand

Name

Type

Constraint

Description

listener

OnFailureListener

Y

Listener, which is called back when a task fails to be executed.

Returns

Expand

Type

Description

Task<TResult>

A task execution result.

addOnFailureListener(Executor executor, OnFailureListener listener)

Expand

Method

public abstract Task<TResult> addOnFailureListener(Executor executor, OnFailureListener listener)

Adds one or more listeners that will be called in a specified executor upon the task execution failure. Multiple listeners added will be called in the order in which they were added.

Parameters

Expand

Name

Type

Constraint

Description

executor

Executor

Y

Executor used for callback.

listener

OnFailureListener

Y

Listener, which is called back when a task fails to be executed.

Returns

Expand

Type

Description

Task<TResult>

A task execution result.

addOnCompleteListener(OnCompleteListener<TResult> listener)

Expand

Method

public Task<TResult> addOnCompleteListener(OnCompleteListener<TResult> listener)

Adds one or more listeners that will be called in the main thread upon task completion. Multiple listeners added will be called in the order in which they were added.

Parameters

Expand

Name

Type

Constraint

Description

listener

OnCompleteListener<TResult>

Y

Listener, which is called back when a task is completed.

Returns

Expand

Type

Description

Task<TResult>

A task execution result.

addOnCompleteListener(Executor executor, OnCompleteListener<TResult> listener)

Expand

Method

public Task<TResult> addOnCompleteListener(Executor executor, OnCompleteListener<TResult> listener)

Adds one or more listeners that will be called in a specified executor upon task completion. Multiple listeners added will be called in the order in which they were added.

Parameters

Expand

Name

Type

Constraint

Description

executor

Executor

Y

Executor used for callback.

listener

OnCompleteListener<TResult>

Y

Listener, which is called back when a task is completed.

Returns

Expand

Type

Description

Task<TResult>

A task execution result.

addOnCanceledListener(Activity activity, OnCanceledListener listener)

Expand

Method

public Task<TResult> addOnCanceledListener(Activity activity, OnCanceledListener listener)

Adds one or more listeners that will be called in a specified executor upon task cancellation. Multiple listeners added will be called in the order in which they were added.

Parameters

Expand

Name

Type

Constraint

Description

activity

Activity

Y

Activity context.

listener

OnCanceledListener

Y

Listener, which is called back when a task is canceled.

Returns

Expand

Type

Description

Task<TResult>

A task execution result.

addOnCanceledListener(OnCanceledListener listener)

Expand

Method

public Task<TResult> addOnCanceledListener(OnCanceledListener listener)

Adds one or more listeners that will be called in the main thread upon task cancellation. Multiple listeners added will be called in the order in which they were added.

Parameters

Expand

Name

Type

Constraint

Description

listener

OnCanceledListener

Y

Listener, which is called back when a task is canceled.

Returns

Expand

Type

Description

Task<TResult>

A task execution result.

addOnCanceledListener(Executor executor, OnCanceledListener listener)

Expand

Method

public Task<TResult> addOnCanceledListener(Executor executor, OnCanceledListener listener)

Adds one or more listeners that will be called in a specified executor upon task cancellation. Multiple listeners added will be called in the order in which they were added.

Parameters

Expand

Name

Type

Constraint

Description

executor

Executor

Y

Executor used for callback.

listener

OnCanceledListener

Y

Listener, which is called back when a task is canceled.

Returns

Expand

Type

Description

Task<TResult>

A task execution result.

onSuccessTask(SuccessContinuation< TResult, TContinuationResult> listener)

Expand

Method

public <TContinuationResult> Task<TContinuationResult> onSuccessTask(SuccessContinuation< TResult, TContinuationResult> listener)

A then method to call the listener after Task<TResult> is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in 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 to be executed, the failure handling will be performed and the listener will not be executed.

Parameters

Expand

Name

Type

Constraint

Description

listener

SuccessContinuation< TResult, TContinuationResult>

Y

API implementation class instance, which implements the then API and is used to call a subsequent task after the current task is executed successfully.

Returns

Expand

Type

Description

Task<TContinuationResult>

A task subsequent to the current task.

onSuccessTask(Executor executor, SuccessContinuation<TResult, TContinuationResult> listener)

Expand

Method

public <TContinuationResult> Task<TContinuationResult> onSuccessTask(Executor executor, SuccessContinuation<TResult, TContinuationResult> listener)

A then method to call the listener after Task<TResult> is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in a 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 to be executed, the failure handling will be performed and the listener will not be executed.

Parameters

Expand

Name

Type

Constraint

Description

executor

Executor

Y

Executor used for callback.

listener

SuccessContinuation<TResult, TContinuationResult>

Y

Listener, which is called back when a task is canceled.

Returns

Expand

Type

Description

Task<TContinuationResult>

A task subsequent to the current task.

continueWithTask(Continuation<TResult, Task<TContinuationResult>> taskContinuation)

Expand

Method

public <TContinuationResult> Task<TContinuationResult> continueWithTask(Continuation<TResult, Task<TContinuationResult>> taskContinuation)

A then method to call the listener after Task<TResult> is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in the main thread. If the current task is canceled, returned taskContinuation will still be executed.

Parameters

Expand

Name

Type

Constraint

Description

taskContinuation

Continuation<TResult, Task<TContinuationResult>

Y

API implementation class instance, which implements the then API and is used to call a subsequent task after the current task is executed successfully.

Returns

Expand

Type

Description

Task<TContinuationResult>

A task subsequent to the current task.

continueWithTask(Executor executor, Continuation<TResult, Task<TContinuationResult>> taskContinuation)

Expand

Method

public <TContinuationResult> Task<TContinuationResult> continueWithTask(Executor executor, Continuation<TResult, Task<TContinuationResult>> taskContinuation)

A then method to call the listener after Task<TResult> is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in the main thread. If the current task is canceled, returned taskContinuation will still be executed.

Parameters

Expand

Name

Type

Constraint

Description

executor

Executor

Y

Executor to execute taskContinuation.

taskContinuation

Continuation<TResult, Task<TContinuationResult>>

Y

API implementation class instance, which implements the then API and is used to call a subsequent task after the current task is executed successfully.

Returns

Expand

Type

Description

Task<TContinuationResult>

A task subsequent to the current task.

continueWith(Executor executor, Continuation<TResult, Task<TContinuationResult>> taskContinuation)

Expand

Method

public <TContinuationResult> Task<TContinuationResult> continueWithTask(Executor executor, Continuation<TResult, Task<TContinuationResult>> taskContinuation)

A then method to call the listener after Task<TResult> is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in a specified executor. If the current task is canceled, returned taskContinuation will still be executed.

Parameters

Expand

Name

Type

Constraint

Description

executor

Executor

Y

Executor to execute taskContinuation.

taskContinuation

Continuation<TResult, Task<TContinuationResult>>

Y

API implementation class instance, which implements the then API and is used to call a subsequent task after the current task is executed successfully.

Returns

Expand

Type

Description

Task<TContinuationResult>

A task subsequent to the current task.

continueWith(Executor executor, Continuation<TResult, TContinuationResult> continuation)

Expand

Method

public <TContinuationResult> Task<TContinuationResult> continueWith(Executor executor, Continuation<TResult, TContinuationResult> continuation)

A then method to call the listener after Task<TResult> is successfully executed. The method returns Task<TContinuationResult> to create a Task<TContinuationResult> task based on the returned result. The listener is executed in a specified executor. If the current task is canceled, returned taskContinuation will not be executed.

Parameters

Expand

Name

Type

Constraint

Description

executor

Executor

Y

Executor to execute Continuation.

taskContinuation

Continuation<TResult, TContinuationResult>

Y

API implementation class instance, which implements the then API and is used to call a subsequent task after the current task is executed successfully.

Returns

Expand

Type

Description

Task<TContinuationResult>

A task subsequent to the current task.

destroy

Expand

Method

public void destroy()

Destroys PublisherAdView. This method needs to be called in onDestroy of the parent activity. No other methods should be called for PublisherAdView after destroy() is called.

Search in References
Enter a keyword.