ShowSecretsSetting
class ShowSecretsSetting
| kotlin.Any | |
| ↳ | android.text.ShowSecretsSetting |
This is the API surface for interacting with the settings that determine whether characters in password inputs or other secret fields are echoed briefly or hidden immediately.
Summary
| Public methods | |
|---|---|
| static Runnable |
registerCallback(context: Context, callback: Runnable)Registers a callback to be notified when show password settings change. |
| static Runnable |
registerCallback(context: Context, executor: Executor, callback: Runnable)Registers a callback to be notified when show password settings change. |
| static Boolean |
shouldShowPhysicalInput(context: Context)Returns |
| static Boolean |
shouldShowTouchInput(context: Context)Returns |
Public methods
registerCallback
static fun registerCallback(
context: Context,
callback: Runnable
): Runnable
Registers a callback to be notified when show password settings change. The callback will be invoked on the main thread.
See registerCallback(Context,Executor,Runnable) regarding context lifetime management.
| Parameters | |
|---|---|
context |
Context: The context used to access settings. This value cannot be null. |
callback |
Runnable: The callback to invoke. This value cannot be null. |
| Return | |
|---|---|
Runnable |
A runnable that unregisters the callback when run. This value cannot be null. |
registerCallback
static fun registerCallback(
context: Context,
executor: Executor,
callback: Runnable
): Runnable
Registers a callback to be notified when show password settings change.
Note: To avoid unintentionally extending the lifetime of the provided context, the actual observer registration is performed using the application context (or a user-specific context derived from it), rather than holding a strong reference to the provided context. However, the user ID of the provided context is preserved to ensure the correct user's settings are monitored. As a fallback, if the application context is null (which typically only occurs in mocked contexts during tests or during very early process initialization), the provided context is used directly. Callers should ensure that in this fallback scenario, the provided context is not an Activity or other short-lived context, as it may result in extending its lifetime indefinitely if the returned runnable is kept alive.
| Parameters | |
|---|---|
context |
Context: The context used to access settings. This value cannot be null. |
executor |
Executor: The executor on which to invoke the callback. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
Runnable: The callback to invoke. This value cannot be null. |
| Return | |
|---|---|
Runnable |
A runnable that unregisters the callback when run. |
shouldShowPhysicalInput
static fun shouldShowPhysicalInput(context: Context): Boolean
Returns true when characters entered into a password, pin or other secret field from hardware/physical input sources should either be shown or echoed briefly.
| Parameters | |
|---|---|
context |
Context: This value cannot be null. |
shouldShowTouchInput
static fun shouldShowTouchInput(context: Context): Boolean
Returns true when characters entered into a password, pin or other secret field from touch/virtual input sources should either be shown or echoed briefly.
| Parameters | |
|---|---|
context |
Context: This value cannot be null. |