Create Custom Keyboard in Android

天大地大妈咪最大 提交于 2019-11-27 19:47:52
Gabe Sechan

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

So first I searched the net but didn't found anything about that

Creating an input method is covered in the Android developer documentation, which is on the Internet.

Do you guys have samplecode?

There is a sample in the samples/ directory of your SDK installation, if you downloaded sample code from the SDK Manager. Look for SoftKeyboard.

Do I need root to do this?

No.

What's the structure behind it? (Is it just a regular Activity with a Service??)

It is an InputMethodService.

Fay007
  1. Is there a good tutorial out there? Do you guys have sample code?

Hereby a good tutorial:
http://code.tutsplus.com/tutorials/create-a-custom-keyboard-on-android--cms-22615

  1. Do I need root to do this?

No, root is not required to do this.

  1. What's the structure behind it? (Is it just a regular Activity with a Service??)

You need to use the inputMethodService, see the documentation.

  1. Is it possible to read out the Inputbox within the keyboard?

root: no

Is it possible to read out the Inputbox within the keyboard?

yes it is possible.

InputConnection ic = getCurrentInputConnection();
String currentText = ic.getExtractedText(new ExtractedTextRequest(), 0).text;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!