'How to identify an input field by an input method service?

I am implementing a custom keyboard and therefore use an input method service. In the onStartInput() method I am able to identify the app, the keyboard is used in, by the packageName of the EditorInfo parameter.

I would like to identy the input field to allow the user to execute certain actions depending on which field he has selected. For example if he uses app XY and select the first field their should be different keys offered to the user than when he selected the second or third field. All fields are regular text fields. To be able to do so, it is necessary to get an ID of the input field.

Does anyone now a solution for this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source