ShowSecretsSetting
public
final
class
ShowSecretsSetting
extends Object
| java.lang.Object | |
| ↳ | 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, Runnable callback)
Registers a callback to be notified when show password settings change. |
static
Runnable
|
registerCallback(Context context, Executor executor, Runnable callback)
Registers a callback to be notified when show password settings change. |
static
boolean
|
shouldShowPhysicalInput(Context context)
Returns |
static
boolean
|
shouldShowTouchInput(Context context)
Returns |
Inherited methods | |
|---|---|
Public methods
registerCallback
public static Runnable registerCallback (Context context, Runnable callback)
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. |
| Returns | |
|---|---|
Runnable |
A runnable that unregisters the callback when run.
This value cannot be null. |
registerCallback
public static Runnable registerCallback (Context context, Executor executor, Runnable callback)
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. |
| Returns | |
|---|---|
Runnable |
A runnable that unregisters the callback when run. |
shouldShowPhysicalInput
public static boolean shouldShowPhysicalInput (Context context)
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. |
| Returns | |
|---|---|
boolean |
|
shouldShowTouchInput
public static boolean shouldShowTouchInput (Context context)
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. |
| Returns | |
|---|---|
boolean |
|