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
:
- Callback methods without
packageName
are invoked. Apps with minSdkVersion lower thanBuild.VERSION_CODES.TIRAMISU
must implement those methods if they want to handle the events. - Callback methods for a particular event may be called multiple times
consecutively, even when the translation state has not changed (e.g.,
onStarted(android.icu.util.ULocale, android.icu.util.ULocale, java.lang.String)
may be called multiple times even after translation has already started).
In Android version Build.VERSION_CODES.TIRAMISU
and later:
- If both methods with and without
packageName
are implemented (e.g.,onFinished()
andonFinished(java.lang.String)
, only the one withpackageName
will be called. - Callback methods for a particular event will not be called multiple times
consecutively. They will only be called when the translation state has actually changed
(e.g., from "started" to "paused"). Note: "resumed" is not considered a separate state
from "started", so
onResumed(android.icu.util.ULocale, android.icu.util.ULocale, java.lang.String)
will never be called afteronStarted(android.icu.util.ULocale, android.icu.util.ULocale, java.lang.String)
.<
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 |
default
void
|
onStarted(ULocale sourceLocale, ULocale targetLocale, String packageName)
The system is requesting translation of the UI from |
Public methods
onFinished
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
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
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
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
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
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
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
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 . |