Added in API level 31

UiTranslationStateCallback

public interface UiTranslationStateCallback

android.view.translation.UiTranslationStateCallback


Callback for listening to UI Translation state changes. See UiTranslationManager.registerUiTranslationStateCallback(java.util.concurrent.Executor, android.view.translation.UiTranslationStateCallback).

Prior to Android version Build.VERSION_CODES.TIRAMISU:

In Android version Build.VERSION_CODES.TIRAMISU and later:

Summary

Public methods

default void onFinished(String packageName)

The UI Translation session has ended.

abstract void onFinished()

The UI Translation session has ended.

abstract void onPaused()

The system is requesting that the application temporarily show the UI contents in their original language.

default void onPaused(String packageName)

The system is requesting that the application temporarily show the UI contents in their original language.

default void onResumed(ULocale sourceLocale, ULocale targetLocale, String packageName)

The system is requesting that the application restore from the temporarily paused state and show the content in the translated language.

default void onResumed(ULocale sourceLocale, ULocale targetLocale)

The system is requesting that the application restore from the temporarily paused state and show the content in the translated language.

default void onStarted(ULocale sourceLocale, ULocale targetLocale)

The system is requesting translation of the UI from sourceLocale to targetLocale.

default void onStarted(ULocale sourceLocale, ULocale targetLocale, String packageName)

The system is requesting translation of the UI from sourceLocale to targetLocale.

Public methods

onFinished

Added in API level 33
public void onFinished (String packageName)

The UI Translation session has ended.

Apps may implement onFinished() instead if they don't need the name of the package that owns the activity being translated.

Apps with minSdkVersion lower than Build.VERSION_CODES.TIRAMISU must implement onFinished() if they want to handle the "finished" event.

Parameters
packageName String: The name of the package that owns the activity being translated. This value cannot be null.

onFinished

Added in API level 31
public abstract void onFinished ()

The UI Translation session has ended.

Apps should implement onFinished(java.lang.String) as well if they need the name of the package that owns the activity being translated.

onPaused

Added in API level 31
public abstract void onPaused ()

The system is requesting that the application temporarily show the UI contents in their original language.

Apps should implement onPaused(java.lang.String) as well if they need the name of the package that owns the activity being translated.

onPaused

Added in API level 33
public void onPaused (String packageName)

The system is requesting that the application temporarily show the UI contents in their original language.

Apps may implement onPaused() instead if they don't need the name of the package that owns the activity being translated.

Apps with minSdkVersion lower than Build.VERSION_CODES.TIRAMISU must implement onPaused() if they want to handle the "paused" event.

Parameters
packageName String: This value cannot be null.

onResumed

Added in API level 33
public void onResumed (ULocale sourceLocale, 
                ULocale targetLocale, 
                String packageName)

The system is requesting that the application restore from the temporarily paused state and show the content in the translated language.

Apps may implement onResumed(android.icu.util.ULocale, android.icu.util.ULocale) instead if they don't need the name of the package that owns the activity being translated.

Apps with minSdkVersion lower than Build.VERSION_CODES.TIRAMISU must implement onResumed(android.icu.util.ULocale, android.icu.util.ULocale) if they want to handle the "resumed" event.

Parameters
sourceLocale ULocale: ULocale the UI is being translated from. This value cannot be null.

targetLocale ULocale: ULocale the UI is being translated to. This value cannot be null.

packageName String: The name of the package that owns the activity being translated. This value cannot be null.

onResumed

Added in API level 31
public void onResumed (ULocale sourceLocale, 
                ULocale targetLocale)

The system is requesting that the application restore from the temporarily paused state and show the content in the translated language.

Apps should implement onResumed(android.icu.util.ULocale, android.icu.util.ULocale, java.lang.String) instead if they need the name of the package that owns the activity being translated.

Apps with minSdkVersion lower than Build.VERSION_CODES.TIRAMISU must implement this method if they want to handle the "resumed" event.

Parameters
sourceLocale ULocale: ULocale the UI is being translated from. This value cannot be null.

targetLocale ULocale: ULocale the UI is being translated to. This value cannot be null.

onStarted

Added in API level 31
public void onStarted (ULocale sourceLocale, 
                ULocale targetLocale)

The system is requesting translation of the UI from sourceLocale to targetLocale.

This is also called if either the requested sourceLocale or targetLocale has changed.

Apps should implement onStarted(android.icu.util.ULocale, android.icu.util.ULocale, java.lang.String) instead if they need the name of the package that owns the activity being translated.

Apps with minSdkVersion lower than Build.VERSION_CODES.TIRAMISU must implement this method if they want to handle the "started" event.

Parameters
sourceLocale ULocale: ULocale the UI is being translated from. This value cannot be null.

targetLocale ULocale: ULocale the UI is being translated to. This value cannot be null.

onStarted

Added in API level 33
public void onStarted (ULocale sourceLocale, 
                ULocale targetLocale, 
                String packageName)

The system is requesting translation of the UI from sourceLocale to targetLocale.

This is also called if either the requested sourceLocale or targetLocale has changed.

Apps may implement onStarted(android.icu.util.ULocale, android.icu.util.ULocale) instead if they don't need the name of the package that owns the activity being translated.

Apps with minSdkVersion lower than Build.VERSION_CODES.TIRAMISU must implement onStarted(android.icu.util.ULocale, android.icu.util.ULocale) if they want to handle the "started" event.

Parameters
sourceLocale ULocale: ULocale the UI is being translated from. This value cannot be null.

targetLocale ULocale: ULocale the UI is being translated to. This value cannot be null.

packageName String: The name of the package that owns the activity being translated. This value cannot be null.