annuaire recherche
android Manifest Manifest.permission Manifest.permission_group android.accessibilityservice AccessibilityService android.accounts Account android.app NotificationManager android.bluetooth BluetoothAdapter BluetoothClass BluetoothClass.Device BluetoothClass.Device.Major BluetoothClass.Service BluetoothDevice BluetoothServerSocket BluetoothSocket android.content SharedPreferences android.database.sqlite SQLiteCursorDriver SQLiteOpenHelper android.graphics Bitmap android.location LocationListener Geocoder GpsStatus GpsStatus.Listener GpsStatus.NmeaListener GpsSatellite android.media AudioFormat AsyncPlayer AudioRecord AudioRecord.OnRecordPositionUpdateListener ThumbnailUtils AudioManager android.net TrafficStats MailTo LocalSocket android.os AsyncTask AsyncTask.Status CountDownTimer Message MessageQueue HandlerThread android.text Html android.util JsonWriter android.view ContextMenu ContextMenu.ContextMenuInfo Display ViewManager View ViewStub ViewTreeObserver ViewParent WindowManager GestureDetector Gravity MenuInflater ScaleGestureDetector SoundEffectConstants android.view.inputmethod InputConnection InputMethod InputMethodSession BaseInputConnection InputMethodManager android.widget AbsListView AbsListView.LayoutParams AbsListView.OnScrollListener AbsListView.RecyclerListener AbsoluteLayout AbsoluteLayout.LayoutParams AbsSeekBar AbsSpinner AdapterView AdapterView.AdapterContextMenuInfo AdapterView.OnItemLongClickListener AdapterView.OnItemSelectedListener AdapterView.OnItemClickListener AnalogClock BaseAdapter BaseExpandableListAdapter Button CheckBox CheckedTextView Checkable Chronometer Chronometer.OnChronometerTickListener CompoundButton CompoundButton.OnCheckedChangeListener CursorAdapter CursorTreeAdapter DatePicker DatePicker.OnDateChangedListener DialerFilter DigitalClock EditText Filter Filter.FilterListener Filter.FilterResults ExpandableListAdapter ExpandableListView.OnChildClickListener ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupCollapseListener ExpandableListView.OnGroupExpandListener Filterable Gallery Gallery.LayoutParams GridView GridLayout GridLayout.Alignment RadioGroup ImageView ImageView.ScaleType HorizontalScrollView ImageButton ImageSwitcher FilterQueryProvider ListAdapter ListView MediaController MultiAutoCompleteTextView MultiAutoCompleteTextView.CommaTokenizer MultiAutoCompleteTextView.Tokenizer QuickContactBadge RadioButton RatingBar RatingBar.OnRatingBarChangeListener RelativeLayout RemoteViews ResourceCursorAdapter ResourceCursorTreeAdapter Scroller ScrollView SearchView SearchView.OnCloseListener SearchView.OnQueryTextListener SearchView.OnSuggestionListener SeekBar SeekBar.OnSeekBarChangeListener SimpleAdapter SimpleAdapter.ViewBinder SimpleCursorAdapter SimpleCursorAdapter.CursorToStringConverter SimpleCursorAdapter.ViewBinder SimpleCursorTreeAdapter SimpleCursorTreeAdapter.ViewBinder SimpleExpandableListAdapter SlidingDrawer SlidingDrawer.OnDrawerCloseListener SlidingDrawer.OnDrawerOpenListener SlidingDrawer.OnDrawerScrollListener Spinner SpinnerAdapter WrapperListAdapter TabHost TabHost.TabSpec TextView TimePicker TimePicker.OnTimeChangedListener Toast TableLayout TableLayout.LayoutParams TableRow TableRow.LayoutParams TabWidget TextSwitcher ToggleButton TwoLineListItem VideoView ViewAnimator ViewFlipper ViewSwitcher ViewSwitcher.ViewFactory ZoomButtonsController ZoomButtonsController.OnZoomListener ZoomButton ZoomControls dalvik.system DexFile
personnages


InputMethod

版本:Android 2.3 r1

 

结构

继承关系

public interface InputMethod extends Object

        

android.view.inputmethod.InputMethod

 

子类及间接子类

间接子类

AbstractInputMethodService.AbstractInputMethodImpl, InputMethodService.InputMethodImpl

 

类概述

InputMethod接口代表了输入法,它可生成按键事件,生成文本,如数字,email地址,CJK字符,其它语言字符等等。在处理输入事件时,将文本返回至需要文本输入的应用程序。InputMethodManager可得到更多关于架构的信息。

应用程序通常不使用这个接口本身,而是依靠TextView EditText提供的标准交互。

输入法实现通常为InputMethodService及其子类的派生。在实现输入法时,包含它的服务控件必须提供SERVICE_META_DATA元数据字段,该元数据字段联接至一包含输入法细节的XML资源。所有输入法也必定要求客户端包含BIND_INPUT_METHOD以便与服务控件交互。如果不这样,系统将无法使用输入法,因其无法确认是否完整。

InputMethod接口实际上分为两部分:接口是输入法的最高级接口,提供所有的访问,只有系统能访问(需要BIND_INPUT_METHOD权限)。另外调用方法createSession(android.view.inputmethod.InputMethod.SessionCallback)可实例化InputMethodSession副接口,用于与客户端通讯。

                  

内部类

         interface          InputMethod.SessionCallback

 

常量

public static final String SERVICE_INTERFACE

接口名字,实现输入法的服务应说明它支持输入法,也就是它将用于意向过滤器(intent filter)。服务还需要BIND_INPUT_METHOD权限,这样应用程序不会滥用它。

常量值: "android.view.InputMethod"

 

public static final String SERVICE_META_DATA

输入法通过此名字发布其自身信息。此元数据必须引用一个包含< input-method>标签的XML资源。

常量值: "android.view.im"

 

public static final int SHOW_EXPLICIT

用于showSoftInput(int, ResultReceiver)的标志:它表示用户显式地要求其(软键盘)显示。如果没有设置,系统决定可能是一个好主意,显示输入法在用户界面上的导航操作。

常量值: 1 (0x00000001)

 

public static final int SHOW_FORCED

标志用于showSoftInput(int, ResultReceiver):表明用户强制其(软键盘)显示。如设置,输入法保持可见直至用户在UI上取消。

常量值: 2 (0x00000002)

       

公共方法

public abstract void attachToken (IBinder token)

输入法创建后首先被调用,它提供一个与系统服务会话的唯一令牌。它需要通过服务识别输入法从而验证其操作。令牌不能传递给应用程序,因其取得了应用程序不应得到的特殊权限。

注意:为避免恶意客户端伤害,你应只接收第一个令牌。其后可能来自客户端。

 

public abstract void bindInput (InputBinding binding)

将输入法与新的应用程序环境绑定,以便稍后启动、停止输入处理。通常在应用程序第一次启用输入法时调用此方法。

参数

binding    与输入法绑定的应用程序窗口信息。

参见

                        InputBinding

                   unbindInput()

 

public abstract void createSession (InputMethod.SessionCallback callback)

创建一个新的InputMethodSession,它可处理客户应用程序与输入法的交互。你可以随后用revokeSession(InputMethodSession)销毁会话,这样就不会有任何客户端使用它。

参数

callback 新创建会话调用的接口。

 

public abstract void hideSoftInput (int flags, ResultReceiver resultReceiver)

将输入法的软键盘(soft input)部分对用户隐藏。

参数

flags        显示要求的附加信息。当前总是0

resultReceiver  向要求显示的客户端通知结果。其结果可能为InputMethodManager.RESULT_UNCHANGED_SHOWN, InputMethodManager.RESULT_UNCHANGED_HIDDEN,InputMethodManager.RESULT_SHOWN, InputMethodManager.RESULT_HIDDEN

 

public abstract void restartInput (InputConnection inputConnection, EditorInfo attribute)

输入法需重置时调用此方法。

通常输入焦点从一个文本框移至另一个时调用此方法。

参数

inputConnection     可选,确定与文本框通讯的输入通讯通道;如为空,你使用通常绑定的输入通讯通道。

attribute          文本框(通常是EditText)需要输入的属性

参见

                            EditorInfo

 

public abstract void revokeSession (InputMethodSession session)

关闭并销毁先前由createSession(android.view.inputmethod.InputMethod.SessionCallback)创建的会话。调用后,会话不再有效,对其的调用将失败。

参数

session  先前由SessionCallback.sessionCreated()提供的InputMethodSession将被吊销。

 

public abstract void setSessionEnabled (InputMethodSession session, boolean enabled).

控制某特定输入法会话是否激活。

参数

session   先前由SessionCallback.sessionCreated()提供的InputMethodSession将改变。

 

public abstract void showSoftInput (int flags, ResultReceiver resultReceiver)

将输入法的软键盘(soft input)部分对用户显示。

参数

flags  提供显示要求的附加信息。当前为0或设置SHOW_EXPLICIT 位。

resultReceiver  向要求显示的客户端通知结果。其结果可能为InputMethodManager.RESULT_UNCHANGED_SHOWN, InputMethodManager.RESULT_UNCHANGED_HIDDEN,InputMethodManager.RESULT_SHOWN, InputMethodManager.RESULT_HIDDEN

 

public abstract void startInput (InputConnection inputConnection, EditorInfo info)

应用程序开始接收文本,输入法准备好为应用程序处理接收事件并返回文本时调用本方法。

参数

inputConnection     可选,确定与文本框通讯的输入通讯通道;如为空,你使用通常绑定的输入通讯通道。

info  需要输入的文本框(通常是EditText)信息。

参见

                        EditorInfo

 

public abstract void unbindInput ()

         解除与应用程序的绑定,先前由bindInput(InputBinding)设定的信息对当前输入法无效时调用。

通常在应用程序变为非前台调用。

补充

文章精选

Android中创建一种新的输入法(Creating an Input Method

Android input method panel control

通过一个SoftKeyboard例子 (可以看看博客里的其他几篇文章)

Android IMF的一处瑕疵

Android IMF输入法总结

Android 平台开发一个输入法

Android IMF学习笔记一

Android Framework系列之IMF(一)

Android Framework系列之IMF(二)

Android Framework系列之IMF(三)

 


Article précédent: Article suivant: