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 functions

createInputConnection

fun createInputConnection(outAttributes: EditorInfo): InputConnection

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

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

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

However it does not guarantee that only one InputConnection will ever be active at a time for a given PlatformTextInputMethodRequest instance. On the other hand Android platform does guarantee that even though the platform may create multiple InputConnections, only one of them will ever communicate with the app, invalidating any other InputConnection that remained open at the time of communication.

Android may call View.onCreateInputConnection multiple times for the same session – each system call will result in a 1:1 call to this method. Unfortunately Android platform may decide to use an earlier InputConnection returned from this function, invalidating the ones that were created later. Please do not rely on the order of calls to this function.

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.