Android text and input --- create input method (1)

Source: Internet
Author: User

The Input Method Editor (IME) is a control that allows users to input text. Android provides an extensible Input Method framework that allows applications to provide users with additional input methods, such as soft keyboard or voice input. Once these input methods are installed, you can select the IME they want from the system settings, and this setting is valid for the entire system, each time only one input method is available. To add an Input Method to the Android system, you must create a class application that inherits the InputMethodService class. In addition, you usually need to create a "settings" Activity to pass the options to the IME service. You can also define a UI for setting and display it as part of the system setting. This article includes the following content: 1. IME lifecycle. 2. declare the IME component in the Application List; 3. ime api 4. design ime ui 5. send text from IME to application 6. use IME sub-type IME to introduce the IME lifecycle: Figure 1. IME lifecycle: The following sections describe how to implement the UI and how code is associated with this lifecycle. In the list, IME is an Android application that contains special IME services. The application inventory file must declare the service, apply for necessary permissions, provide Intent filters that match the action. view. InputMethod operation, and define the metadata of IME features. In addition, a setting interface is provided to allow users to use it to edit IME behaviors. You can define a "settings" Activity that can be started from system settings. The following list snippet declares the IME service. It applies for the BIND_INPUT_METHOD permission to allow services to connect to the system's IME, creates an Intent filter that matches the android. view. InputMethod operation, and defines metadata for IME: <! -- Declares the input method service --> <service android: name = "FastInputIME" android: label = "@ string/fast_input_label" android: permission = "android. permission. BIND_INPUT_METHOD "> <intent-filter> <action android: name =" android. view. inputMethod "/> </intent-filter> <meta-data android: name =" android. view. im "android: resource =" @ xml/method "/> </service> next, declare the Activity for setting to IME. It has an Intent filter of the ACTION_MAIN type, which indicates that the Activity is the main entry of the IME application: <! -- Optional: an activity for controlling the IME settings --> <activity android: name = "FastInputIMESettings" android: label = "@ string/fast_input_settings"> <intent-filter> <action android: name = "android. intent. action. MAIN "/> </intent-filter> </activity> You can also provide direct access to IME settings in the UI of this setting.

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.