Android2009-10-24••IMF•KeyEvent•IME•JNI•✦vs.✦vs.IMFKeyEvent•android.view.ViewRoot•com.android.server.WindowManagerService==ViewRoot•ViewRoot:deliveryKeyEvent()•View.dispatchKeyEventPreIme()•InputMethodManager.dispatchEvent()•ViewRoot:deliverKeyEventToViewHierachy()•android.view.inputmethod.InputMethodManager•showInputMethodPicker()•mCurMethod.dispatchKeyEvent()IME••IME••IME•••IME-•androidcreateproject--packagecom.redirectin.android.ime--nameiCosta--activityiCosta--target2--path.•androidcreateavd--target2--path/android/avd/goldfish--namegoldfish•emulator-avdgoldfish•antdebug|install|reinstallTip:~sdk1.5\platforms\android-1.5\templates\android_rules.xmlIME-•AndroidManifest.xml•res/xml/method.xmlIME-IME-•editor:InputConnectiononCreateInputConnection(EditorInfo)•editor:.inputTypeIME-•✦ViewGUI✦Keyboard/KeyboardView•✦IMEServiceIME-•getCurrentInputConnection().commitText(charSeq,1)IME-•SoundAudioManageram=Context.getSystemService(Context.AUDIO_SERVICE);am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD,FX_VOLUME/*1.0f*/);•Vibrateandroid.os.Vibrateorv=(Vibrator)getSystemService(vibrator);v.vibrate(long[]{1,20},-1);IME-•ShowPreferenceinSettings1.registersettingsactivityinappmanifest2.setsettingsActivityattributeofinput-methodtag,inres/xml/method.xml•Read/writepreferenceandroid.content.SharedPreferences:Context.getSharedPreference()JNI•IMEJNI?•Toolchain•AndroidJNI•Toolchain••Androidsourcecode•NDKNDKinSourcecode•Android.mk•make${LOCAL_MODULE}NDK•gccarm-eabi••makeAPP=your-app-name•Application.mk:APP_MODULES•Android.mkAndroidJNI•.so=libs/armeabi•/data/data/pkg_name/lib/libxxx.so•java:System.load(“xxx”);