TranslationManager.CreateOnDeviceTranslator Method

Definition

Creates an on-device Translator for natural language translation.

[Android.Runtime.Register("createOnDeviceTranslator", "(Landroid/view/translation/TranslationContext;Ljava/util/concurrent/Executor;Ljava/util/function/Consumer;)V", "", ApiSince=31)]
public void CreateOnDeviceTranslator (Android.Views.Translation.TranslationContext translationContext, Java.Util.Concurrent.IExecutor executor, Java.Util.Functions.IConsumer callback);
[<Android.Runtime.Register("createOnDeviceTranslator", "(Landroid/view/translation/TranslationContext;Ljava/util/concurrent/Executor;Ljava/util/function/Consumer;)V", "", ApiSince=31)>]
member this.CreateOnDeviceTranslator : Android.Views.Translation.TranslationContext * Java.Util.Concurrent.IExecutor * Java.Util.Functions.IConsumer -> unit

Parameters

translationContext
TranslationContext

TranslationContext containing the specs for creating the Translator.

executor
IExecutor

Executor to run callback operations

callback
IConsumer

Consumer to receive the translator. A null value is returned if the service could not create the translator.

Attributes

Remarks

Creates an on-device Translator for natural language translation.

In Android 12, this method provided the same cached Translator object when given the same TranslationContext object. Do not use a Translator destroyed elsewhere as this will cause an exception on Android 12.

In later versions, this method never returns a cached Translator.

Java documentation for android.view.translation.TranslationManager.createOnDeviceTranslator(android.view.translation.TranslationContext, java.util.concurrent.Executor, java.util.function.Consumer<android.view.translation.Translator>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to