TranslationResponse


public final class TranslationResponse
extends Object implements Parcelable

java.lang.Object
   ↳ android.view.translation.TranslationResponse


Response from the translation service, which contains the translated result.

Summary

Nested classes

class TranslationResponse.Builder

A builder for TranslationResponse 

Constants

int TRANSLATION_STATUS_CONTEXT_UNSUPPORTED

The languages of the request is not available to be translated.

int TRANSLATION_STATUS_SUCCESS

The translation service was successful in translating.

int TRANSLATION_STATUS_UNKNOWN_ERROR

The translation service returned unknown translation result.

Inherited constants

Fields

public static final Creator<TranslationResponse> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

SparseArray<TranslationResponseValue> getTranslationResponseValues()

List of translated TranslationResponseValues.

int getTranslationStatus()

The translation result status code.

SparseArray<ViewTranslationResponse> getViewTranslationResponses()

List of translated ViewTranslationResponses.

boolean isFinalResponse()

Whether this response contains complete translated values, or is the final response in a series of partial responses.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

TRANSLATION_STATUS_CONTEXT_UNSUPPORTED

Added in API level 31
public static final int TRANSLATION_STATUS_CONTEXT_UNSUPPORTED

The languages of the request is not available to be translated.

Constant Value: 2 (0x00000002)

TRANSLATION_STATUS_SUCCESS

Added in API level 31
public static final int TRANSLATION_STATUS_SUCCESS

The translation service was successful in translating.

Constant Value: 0 (0x00000000)

TRANSLATION_STATUS_UNKNOWN_ERROR

Added in API level 31
public static final int TRANSLATION_STATUS_UNKNOWN_ERROR

The translation service returned unknown translation result.

Constant Value: 1 (0x00000001)

Fields

CREATOR

Added in API level 31
public static final Creator<TranslationResponse> CREATOR

Public methods

describeContents

Added in API level 31
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getTranslationResponseValues

Added in API level 31
public SparseArray<TranslationResponseValue> getTranslationResponseValues ()

List of translated TranslationResponseValues. The key of entries in this list will be their respective index in TranslationRequest#getTranslationRequestValues().

Returns
SparseArray<TranslationResponseValue> This value cannot be null.

getTranslationStatus

Added in API level 31
public int getTranslationStatus ()

The translation result status code.

Returns
int Value is TRANSLATION_STATUS_SUCCESS, TRANSLATION_STATUS_UNKNOWN_ERROR, or TRANSLATION_STATUS_CONTEXT_UNSUPPORTED

getViewTranslationResponses

Added in API level 31
public SparseArray<ViewTranslationResponse> getViewTranslationResponses ()

List of translated ViewTranslationResponses. The key of entries in this list will be their respective index in TranslationRequest#getViewTranslationRequests().

Returns
SparseArray<ViewTranslationResponse> This value cannot be null.

isFinalResponse

Added in API level 31
public boolean isFinalResponse ()

Whether this response contains complete translated values, or is the final response in a series of partial responses.

This is true by default.

Returns
boolean

toString

Added in API level 31
public String toString ()

Returns a string representation of the object.

Returns
String a string representation of the object.

writeToParcel

Added in API level 31
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES