What are the classes that implement the default Android soft keyboards, the ones you get when you define EditText
with android:inputType="text"
or other possible values of android:inputType?
(I want to see how these classes work, to introduce some additional functionality into them.)
I have found that the keyboard is not part of my Activity
, and moreover, the OnTouch events of keyboard do not go through Activity.dispatchTouchEvent(..)
.
This agrees with the documentation that says that the keyboard runs in a service, apparently meaning that it is run in a different thread and is not part of the Activity
containing the EditText
element, among other things.
It also says that this service is implemented by InputMethodService
.
I hoped to find these classes by setting breakpoints in InputMethodService
in various places, including its onCreate(..)
method. None of these breakpoints was hit.
So I found no way to get to these classes.
Any help?
Thanks
InputMethodService is the base class of all soft keyboard. However there is no default soft keyboard. Each one is its own completely separate app. Every OEM decides independently which app to use.
That's why your breakpoints failed- because the breakpoint would need to have been put in a different app (the keyboard app). You'd have more luck putting breakpoints in EditableInputConnection, which is the implementation of the communication bridge between the two apps for TextView and EditView.
IF you're interested in seeing the code, look at https://android.googlesource.com/platform/packages/inputmethods/LatinIME/+/refs/heads/master That's Google's basic keyboard. It can show you how things work, but IIRC it isn't written for readability. Of course its been 8 years since I've written a keyboard, maybe its gotten better. The direct link to the InputMethodService is https://android.googlesource.com/platform/packages/inputmethods/LatinIME/+/refs/heads/master/java/src/com/android/inputmethod/latin/LatinIME.java