Added in API level 31

Translator


open class Translator
kotlin.Any
   ↳ android.view.translation.Translator

The Translator for translation, defined by a TranslationContext.

Summary

Public methods
open Unit

Destroy this Translator.

open Boolean

Returns whether or not this Translator has been destroyed.

open Unit
translate(request: TranslationRequest, cancellationSignal: CancellationSignal?, executor: Executor, callback: Consumer<TranslationResponse!>)

Requests a translation for the provided TranslationRequest using the Translator's source spec and destination spec.

Public methods

destroy

Added in API level 31
open fun destroy(): Unit

Destroy this Translator.

isDestroyed

Added in API level 31
open fun isDestroyed(): Boolean

Returns whether or not this Translator has been destroyed.

See Also

translate

Added in API level 31
open fun translate(
    request: TranslationRequest,
    cancellationSignal: CancellationSignal?,
    executor: Executor,
    callback: Consumer<TranslationResponse!>
): Unit

Requests a translation for the provided TranslationRequest using the Translator's source spec and destination spec.

Parameters
request TranslationRequest: TranslationRequest request to be translate. This value cannot be null.
cancellationSignal CancellationSignal?: signal to cancel the operation in progress. This value may be null.
executor Executor: Executor to run callback operations This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.
callback Consumer<TranslationResponse!>: Consumer to receive the translation response. Multiple responses may be received if TranslationRequest.FLAG_PARTIAL_RESPONSES is set. This value cannot be null.
Return
Unit This value may be null.
Exceptions
java.lang.IllegalStateException if this Translator session was destroyed when called.