Search code examples
androidandroid-edittextinputconnection

Android: What is an InputConnectionWrapper and what does it do?


I looked into the official documentation but there was only a single line telling me that it's a wrapper class for proxying calls to another input connection. I didn't understand what it said.

I want to know :

  1. what actually is InputConnectionWrapper and what does it do ?
  2. what is sendKeyEvent(Keyevent keyevent) [one of it's method to override] ?

Solution

  • InputConnectionWrapper class is a helper class or a class built using InputConnection class. Where the use of InputConnection class is

    The InputConnection interface is the communication channel from an InputMethod back to the application that is receiving its input. It is used to perform such things as reading text around the cursor, committing text to the text box, and sending raw key events to the application.

    Which means that we can read/perform operations from an input view from different scenario's. For example: getTextAfterCursor method helps to obtain the text after the cursor.

    sendKeyEvent method is to send a key event to the input view, like backpress, return etc.