Android IMF input method summary

Source: Internet
Author: User

IMF is short for the input method framework. It is an important new feature added to Android 1.5. It is used to support soft keyboards and various input methods.
So far (), Android 1.5 has not yet been officially released, but the functions of the IMF have been very stable and there are already three input methods. They are
Latinime (soft keyboard), openwnn (CJK input method), pinyinime (Google pinyin), but also lacks Chinese handwriting and five strokes.
Although you can write the desired input method according to the existing input method module. However, understanding the underlying things is helpful for writing new input methods.
Location of related code:
Frameworks/base/CORE/Java/COM/Android/Internal/View/
IMF Interface Definition
Frameworks/base/CORE/Java/Android/View/inputmothod/
IMF Client
Frameworks/base/CORE/Java/Android/inputmethodservice/
IMF Server
Frameworks/base/services/Java/COM/Android/Server/inputmethodmanagerservice. Java
Input Method Management Service
Packages/inputmethods/
Existing input methods
Development/samples/softkeyboard/
Soft Keyboard example
Frameworks/base/CORE/Java/Android/View/view. Java
Frameworks/base/CORE/Java/Android/widget/textview. Java
Interaction between controls and input methods
According to the SDK documentation, the IMF consists of three main parts:
1. Input Method Manager (IMM)
It is equivalent to the client API, coordinates the interaction between other parts, and communicates with the System Service (imms.
2. Input Method (IME)
Interface and Input Method engine to process user input.
3. Client Applications
Some information is transmitted. Imm is used to determine the focus and IME status. Ime can only have one client connection at a time.
Inputmethodmanager
During instantiation, it will connect to the imms service, and then some calls will request the imms service.
Inputmethodmanagerservice
Process requests from inputmethodmanager and manage the input method service.
During initialization, you will do the following:
1. register some system events and process the interaction between the events (switching screen, closing system dialog box, and changing package) and the input method. For example, the input method menu is closed when the screen is turned off;
When the input method package is deleted, the input method is removed from the available list.
2. Load the input method list (buildinputmethodlistlocked) and read the enabled input method. If it is set to null, load all input methods and select a default input method.
3. Load the status bar icon and the DB server.
Interaction between view and Input Method
Onfocuschanged ()
Call Imm. focusout () to get the focus call Imm. focusin ()
Onwindowfocuschanged
Call Imm. focusout () to get the focus call Imm. focusin ()
Interaction between textview and Input Method
Setinputtype ()
After the input method type is changed, Imm. restartinput () will be restarted ()
Oneditexception ()
After receiving the input completion event, hide the input method interface Imm. hidesoftinputfromwindow ()
Ondraw ()
The content in the input box is changed. The Imm. updateextractedtext content of the input method is updated.
The text in the input box is selected, and the selection information of the update input method is Imm. updateselection.
The cursor position in the input box is changed. The cursor position in the input method is updated to Imm. updatecursor.
PS. Imm. iswatchingcursor
Onkeyup ()
After receiving the keycode_dpad_center button event, the input method interface Imm. showsoftinput is displayed. This event is left-clicked, and the focus is obtained from the input box.
The keyevent. keycode_enter key event is received. The input state is completed. The Imm. hidesoftinputfromwindow () interface is closed ()
Ontouchevent ()
Touch screen events. The input box gets the focus and displays the input method interface Imm. showsoftinput.
Isinputmethodtarget ()
Call Imm. isactive () to determine whether the input method is enabled for this control.
Ontextcontextmenuitem ()
If you select "Switch Input Method" (id_switch_input_method), the input method menu Imm. showinputmethodpicker is displayed.
Setkeylistener ()
Restart the input method Imm. restartinput () for each call ()
Settext ()
The content in the input box is changed. Restart the input method Imm. restartinput ()

 

From: http://www.getideas.cn /? P = 231

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.