Android text and input to create an input method tutorial _android

Source: Internet
Author: User

An Input Method Editor (IME) is a control that lets users enter text. Android provides an extensible framework for input methods that allow applications to provide users with additional input methods, such as soft keyboards or voice input. Once these input methods are installed, users can select the IME they want to use from the setup of the system, and this setting is valid for the entire system, and only one input method is available at a time.

To add an input method to the Android system, you create a class application that contains the inherited Inputmethodservice class. In addition, you typically create a "settings" activity that passes the option to the IME service. You can also define a UI for the settings, and make it appear as part of the system setup.

This article contains the following elements :

1. The life cycle of the IME.

2. Declare the IME component in the application's manifest;

3. IME API

4. Design the UI for the IME

5. Send the Wenbenfal to the application from the IME

6. Use IME subtype

The life cycle of an IME

The following illustration describes the life cycle of an IME:

Figure 1. The life cycle of an IME

The following sections describe how to implement the UI and how the code is associated with this lifecycle.

Life IME component in the manifest

In Android, an IME is an Android application that contains a special IME service. The application's manifest file must declare the service, request the necessary permissions, provide a intent filter that matches the Action.view.InputMethod operation, and metadata that defines the attributes of the IME. Also, provide a setup interface that allows users to edit the IME's behavior, and you can define a "settings" activity that can be started from the system setup.

The following manifest fragment declares the IME service. It applies the Bind_input_method permission to allow the service to connect to the system's IME, establishes a intent filter that matches the Android.view.InputMethod operation, and defines the metadata for the IME:

Copy Code code as follows:

<!--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, you declare an activity for the IME to set up. It has a action_main type of intent filter, which indicates that the activity is the main entry point for an IME application:
Copy Code code as follows:

<!--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.

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.