{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

PlatformTextInputPluginRegistry

@ExperimentalTextApi
public sealed interface PlatformTextInputPluginRegistry

Known direct subclasses
PlatformTextInputPluginRegistryImpl

Implementation of PlatformTextInputPluginRegistry that manages a map of adapters to cached services and allows retrieval of the first active one.


The entry point to the text input plugin API.

This is a low-level API for code that talks directly to the platform input method framework (i.e. InputMethodManager). Higher-level text input APIs in the Foundation library are more appropriate for most cases. The only time a new service type and adapter should be defined is if you are building your own text input system from scratch, including your own TextField composables.

It is expected that the total number of adapters for a given registry will be only one in most cases, or two in rare cases where an entirely separate text input system – from platform IME client to TextField composables – is being used in the same composition.

See rememberAdapter for more information.

Summary

Public methods

abstract @NonNull T

Returns an instance of the PlatformTextInputAdapter type T specified by plugin.

Public methods

rememberAdapter

@Composable
abstract @NonNull T <T extends PlatformTextInputAdapter> rememberAdapter(
    @NonNull PlatformTextInputPlugin<@NonNull T> plugin
)

Returns an instance of the PlatformTextInputAdapter type T specified by plugin.

The returned adapter instance will be shared by all callers of this method passing the same plugin object. The adapter will be created when the first call is made, then cached and returned by every subsequent call in the same or subsequent compositions. When there are no longer any calls to this method for a given plugin, the adapter instance will be PlatformTextInputAdapter.onDisposed.

Parameters
<T extends PlatformTextInputAdapter>

The type of PlatformTextInputAdapter that plugin creates.

@NonNull PlatformTextInputPlugin<@NonNull T> plugin

The factory for adapters and the key into the cache of those adapters.