I'd like to write an custom keyboard which should work on all devices that are running Android 4.0 and up. So first I searched the net but didn't found anything about that. So how can I create an app which replaces the stock keyboard of Android?
What I'd like to know:
- Is there a good tutorial out there? Do you guys have sample code?
- Do I need root to do this?
- What's the structure behind it? (Is it just a regular Activity with a Service??)
- Is it possible to read out the Inputbox within the keyboard?
So, I did this for about 2 years, when I worked on Swype. You don't need root, you just need to implement an InputMethodService. You can get the text out of most textboxes, but not all (not all edit fields correctly implement their half of the APIs. Particularly anything with an input type INPUT_TYPE_NULL will not work well). To get the text you would call inputConnection.getExtractedText
Be warned- the API is bad, and apps are hit and miss on working with it. A basic keyboard is easy, but try and do anything complex and you'll spend a lot of time. A lot of man hours went in to the big keyboards
Hereby a good tutorial:
http://code.tutsplus.com/tutorials/create-a-custom-keyboard-on-android--cms-22615
No, root is not required to do this.
You need to use the
inputMethodService
, see the documentation.root: no
yes it is possible.
Creating an input method is covered in the Android developer documentation, which is on the Internet.
There is a sample in the
samples/
directory of your SDK installation, if you downloaded sample code from the SDK Manager. Look forSoftKeyboard
.No.
It is an
InputMethodService
.