PlatformTextInputMethodRequest



Represents a request to open a platform-specific text input session via PlatformTextInputModifierNode.textInputSession.

Summary

Public functions

InputConnection

Called when the platform requests an InputConnection via View.onCreateInputConnection.

android

Public properties

InputMethodListener

The InputMethodListener that will be registered via Component.addInputMethodListener while the session is active.

android
InputMethodRequests

The InputMethodRequests that will be returned from the Compose host's Component.getInputMethodRequests while the session is active.

android

Public functions

createInputConnection

fun createInputConnection(outAttributes: EditorInfo): InputConnection

Called when the platform requests an InputConnection via View.onCreateInputConnection.

This method makes stricter ordering guarantees about the lifetime of the returned InputConnection than Android does, to make working with connections simpler. Namely, it guarantees:

  • For a given PlatformTextInputMethodRequest instance, only one InputConnection will ever be active at a time.

  • References to an InputConnection will be cleared as soon as the connection becomes inactive. Even if Android leaks its reference to the connection, the connection returned from this method will not be leaked.

  • On API levels that support InputConnection.closeConnection (24+), a connection will always be closed before a new connection is requested.

Android may call View.onCreateInputConnection multiple times for the same session – each system call will result in a 1:1 call to this method, although the old connection will always be closed first.

Parameters
outAttributes: EditorInfo

The EditorInfo from View.onCreateInputConnection.

Returns
InputConnection

The InputConnection that will be used to talk to the IME as long as the session is active. This connection will not receive any calls after the requesting coroutine is cancelled.

Public properties

inputMethodListener

val inputMethodListenerInputMethodListener

The InputMethodListener that will be registered via Component.addInputMethodListener while the session is active.

inputMethodRequests

val inputMethodRequestsInputMethodRequests

The InputMethodRequests that will be returned from the Compose host's Component.getInputMethodRequests while the session is active.