Share via


UiTranslationManager.RegisterUiTranslationStateCallback Method

Definition

Register for notifications of UI Translation state changes on the foreground Activity.

[Android.Runtime.Register("registerUiTranslationStateCallback", "(Ljava/util/concurrent/Executor;Landroid/view/translation/UiTranslationStateCallback;)V", "", ApiSince=31)]
public void RegisterUiTranslationStateCallback (Java.Util.Concurrent.IExecutor executor, Android.Views.Translation.IUiTranslationStateCallback callback);
[<Android.Runtime.Register("registerUiTranslationStateCallback", "(Ljava/util/concurrent/Executor;Landroid/view/translation/UiTranslationStateCallback;)V", "", ApiSince=31)>]
member this.RegisterUiTranslationStateCallback : Java.Util.Concurrent.IExecutor * Android.Views.Translation.IUiTranslationStateCallback -> unit

Parameters

executor
IExecutor
callback
IUiTranslationStateCallback

the callback to register for receiving the state change notifications

Attributes

Remarks

Register for notifications of UI Translation state changes on the foreground Activity. This is available to the owning application itself and also the current input method.

The application whose UI is being translated can use this to customize the UI Translation behavior in ways that aren't made easy by methods like View#onCreateViewTranslationRequest(int[], Consumer).

Input methods can use this to offer complementary features to UI Translation; for example, enabling outgoing message translation when the system is translating incoming messages in a communication app.

Starting from android.os.Build.VERSION_CODES#TIRAMISU, if Activities are already being translated when a callback is registered, methods on the callback will be invoked for each translated activity, depending on the state of translation: <ul> <li>If translation is <em>not</em> paused, UiTranslationStateCallback#onStarted will be invoked.</li> <li>If translation <em>is</em> paused, UiTranslationStateCallback#onStarted will first be invoked, followed by UiTranslationStateCallback#onPaused.</li> </ul>

Java documentation for android.view.translation.UiTranslationManager.registerUiTranslationStateCallback(java.util.concurrent.Executor, android.view.translation.UiTranslationStateCallback).

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