A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/android/reference/com/google/android/gms/tasks/Continuation below:

Continuation | Google Play services

Stay organized with collections Save and categorize content based on your preferences.

public interface Continuation<TResult, TContinuationResult>

A function that is called to continue execution after completion of a Task.

Parameters <TResult>

the Task's result type

<TContinuationResult>

the Continuation's result type

Summary Public methods abstract TContinuationResult then(@NonNull Task<TResult> task)

Returns the result of applying this Continuation to task.

Public methods
abstract TContinuationResult then(@NonNull Task<TResult> task)

Returns the result of applying this Continuation to task.

To propagate failure from the completed Task call getResult and allow the RuntimeExecutionException to propagate. The RuntimeExecutionException will be unwrapped such that the Task returned by continueWith or continueWithTask fails with the original exception.

To suppress specific failures call getResult and catch the exception types of interest:

task.continueWith(new Continuation<String, String>() {
    @Override
    public String then(Task<String> task) {
        try {
            return task.getResult(IOException.class);
        } catch (FileNotFoundException e) {
            return "Not found";
        } catch (IOException e) {
            return "Read failed";
        }
    }
}

To suppress all failures guard any calls to getResult with isSuccessful:

task.continueWith(new Continuation<String, String>() {
    @Override
    public String then(Task<String> task) {
        if (task.isSuccessful()) {
            return task.getResult();
        } else {
            return DEFAULT_VALUE;
        }
    }
}
Parameters @NonNull Task<TResult> task

the completed Task. Never null

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-10-31 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["`Continuation` is an interface used to define a function for continuing execution after a `Task` completes."],["It provides a `then` method that takes the completed `Task` as input and returns the result of the continuation."],["The `then` method can handle success and failure states of the preceding `Task` and define the subsequent behavior."],["You can propagate, suppress specific, or suppress all failures from the preceding `Task` using methods like `getResult()` and `isSuccessful()`."]]],["The `Continuation` interface is a function for post-`Task` execution. It uses a `then` method to apply the continuation to a completed `Task`. The `then` method can return a result of `TContinuationResult` type. Failures from the completed Task can be propagated through `getResult`, or specific exceptions handled by using `getResult` with the exception class or suppress all errors with `isSuccessful`. The `then` method accepts a non-null completed Task as a parameter and may throw an exception.\n"]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4