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()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  | 
Public methods
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: TranslationRequestrequest to be translate. This value cannot benull. | 
| 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 thisExecutor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can useContext.getMainExecutor(). Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| callback | Consumer<TranslationResponse!>: Consumerto receive the translation response. Multiple responses may be received ifTranslationRequest.FLAG_PARTIAL_RESPONSESis set. This value cannot benull. | 
| Return | |
|---|---|
| Unit | This value may be null. | 
| Exceptions | |
|---|---|
| java.lang.IllegalStateException | if this Translator session was destroyed when called. | 
