Android Chinese api (81) -- InputMethod [input method]

Source: Internet
Author: User

Preface

This chapter is about android. view. inputmethod. InputMethod. It is about the input method. The version is Android 2.3 r1 and translated from "liubizhi". Welcome to his blog: http://www.cnblogs.com/zcmky/. thank you again for "liubizhi "! I look forward to you join the Android API Chinese translation, contact me over140@gmail.com.

 

Statement

You are welcome to repost, but please keep the original source of the article :)

Blog Garden: http://www.cnblogs.com/

Android Chinese translation group: http://code.taobao.org/project/view/404/

 

Body

I. Structure

Public interface InputMethod extends Object

Android. view. inputmethod. InputMethod

 

Indirect subclass

AbstractInputMethodService. AbstractInputMethodImpl, InputMethodService. InputMethodImpl

 

Ii. Category Overview

The InputMethod interface represents the input method. It can generate key events and text, such as numbers, email addresses, CJK characters, and other language characters. When processing input events, the text is returned to the application that requires text input.InputMethodManagerYou can get more information about the architecture.

Generally, applications do not use this interface, but rely on the standard interaction provided by TextView and EditText.

The input method is usuallyInputMethodServiceAnd its subclass. When implementing the input method, the service control that contains it must provideSERVICE_META_DATAMetadata field, which is connected to an XML resource that contains the input method details. All input methods must also containBIND_INPUT_METHODTo interact with service controls. If this is not the case, the system will not be able to use the input method because it cannot confirm whether it is complete.

The InputMethod interface is actually divided into two parts: the interface is the most advanced interface of the input method, providing all access, only the system can access (BIND_INPUT_METHOD permission is required ). In addition, call MethodscreateSession(android.view.inputmethod.InputMethod.SessionCallback)InstantiatedInputMethodSessionSecondary interface for communication with the client.

 

Iii. Internal class

Interface InputMethod. SessionCallback

 

Iv. Constants

Public static final StringSERVICE_INTERFACE

Interface Name. The service that implements the input method should indicate that it supports the input method, that is, it will be used for the intent filter ). The Service also needsBIND_INPUT_METHODPermission, so that the application will not abuse it.

Constant Value: "android. view. InputMethod"

 

Public static final StringSERVICE_META_DATA

The input method uses this name to publish its own information. This metadata must referenceinput-method> Tag XML resource.

Constant Value: "android. view. im"

 

Public static final intSHOW_EXPLICIT

UsedshowSoftInput(int, ResultReceiver)It indicates that the user explicitly requires its (soft keyboard) display. If no settings are set, the system may decide that it is a good idea to display the navigation operation of the Input Method on the user interface.

Constant Value: 1 (0x00000001)

 

Public static final intSHOW_FORCED

FlagshowSoftInput(int, ResultReceiver): Indicates that the user is forced to display it on a soft keyboard. If set, the input method remains visible until the user cancels it on the UI.

Constant Value: 2 (0x00000002)

 

V. Public Methods

Public abstract voidAttachToken(IBinder token)

The input method is called first after it is created. It provides a unique token for session with system services. It needs to verify its operation through the service identification input method. The token cannot be passed to the application because it has obtained the special permissions that the application cannot obtain.

Note: To avoid malicious client damage, you should only receive the first token. Later, it may come from the client.

 

Public abstract voidBindInput(InputBinding binding)

Bind the Input Method to the new application environment to start and stop input processing later. This method is usually called when an application enables the input method for the first time.

Parameters

The application window information bound by the binding and input methods.

See

InputBinding

unbindInput()

 

Public abstract voidCreateSession(InputMethod. SessionCallback callback)

Create a new InputMethodSession to process the interaction between the customer application and the input method. You can userevokeSession(InputMethodSession)Destroys a session so that no client can use it.

Parameters

Callback: the newly created API called by the session.

 

Public abstract voidHideSoftInput(Int flags, ResultReceiver resultReceiver)

Hide the soft input part of the input Method to the user.

Parameters

Flags displays the required additional information. Currently, it is always 0.

ResultReceiver sends the notification result to the client. The result may be InputMethodManager. RESULT_UNCHANGED_SHOWN, InputMethodManager. RESULT_UNCHANGED_HIDDEN, InputMethodManager. RESULT_SHOWN, or InputMethodManager. RESULT_HIDDEN.

 

Public abstract voidRestartInput(InputConnection inputConnection, EditorInfo attribute)

This method is called when the input method needs to be reset.

This method is usually called when the input focus is moved from one text box to another.

Parameters

InputConnection (optional) determines the input communication channel to communicate with the text box. If it is null, you use the input communication channel that is usually bound.

Attribute text box (usually EditText)

See

EditorInfo

 

Public abstract voidRevokeSession(InputMethodSession)

Close and destroy the previouscreateSession(android.view.inputmethod.InputMethod.SessionCallback)The created session. After the call, the session is no longer valid and the call to it will fail.

Parameters

The InputMethodSession previously provided by SessionCallback. sessionCreated () will be revoked.

 

Public abstract voidSetSessionEnabled(InputMethodSession session, boolean enabled ).

Controls whether a session of a specific input method is activated.

Parameters

The InputMethodSession previously provided by SessionCallback. sessionCreated () will change.

 

Public abstract voidShowSoftInput(Int flags, ResultReceiver resultReceiver)

Display the soft input part of the input Method to the user.

Parameters

Flags provides additional information required for display. The current value is 0 or the SHOW_EXPLICIT bit is set.

ResultReceiver sends the notification result to the client. The result may be InputMethodManager. RESULT_UNCHANGED_SHOWN, InputMethodManager. RESULT_UNCHANGED_HIDDEN, InputMethodManager. RESULT_SHOWN, or InputMethodManager. RESULT_HIDDEN.

 

Public abstract voidStartInput(InputConnection inputConnection, EditorInfo info)

The application starts to receive text. This method is called when the input method is ready for the application to process the received event and return the text.

Parameters

InputConnection (optional) determines the input communication channel to communicate with the text box. If it is null, you use the input communication channel that is usually bound.

The text box (usually EditText) to be entered in info.

See

EditorInfo

 

Public abstract voidUnbindInput()

Unbind from the application.bindInput(InputBinding)The specified information is invalid for the current input method.

Generally, applications become non-foreground calls.

 

Vi. Supplement

Article Selection

Create a new Input Method (Creating an Input Method) in Android)

Android input method panel control

Using a SoftKeyboard example (you can see several other articles in the blog)

A flaw in the Android IMF

Android IMF input method summary

Develop an input method for the Android platform

Android IMF study Note 1

IMF for Android Framework series (1)

IMF for Android Framework series (II)

IMF for Android Framework series (III)

 

 

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.