In order to verify that an example was written
The first is the input method
public class Remotekeyboard extends Inputmethodservice { @Override public boolean onKeyDown (int keycode, KeyEvent event) { if (Processkey (event, 0! = Event.getrepeatcount ())) return true; Return Super.onkeydown (KeyCode, event); } @Override public boolean onKeyUp (int keycode, keyevent event) { if (Processkey (event, true)) return true; Return Super.onkeyup (KeyCode, event); } Private Boolean Processkey (KeyEvent event, Boolean doIt) { log.e ("=======", "============ Processkey"); return Fals e;}}
Next is the app view
Final TextView Et1 = (TextView) Findviewbyid (R.ID.EDITTEXT1); Et1.setonkeylistener (new Onkeylistener () { @Override Public Boolean OnKey (View v, int keycode, keyevent event) { log.e ("====================", "====onkeylistener"); }
Run Program Print
============================: ============ Processkey
====================: ====onkeylistener
============================: ============ Processkey
====================: ====onkeylistener
The first time should be KeyDown, the second time should be KeyUp, indicating that the Android IME interception key takes precedence over the view
And experimented with rewriting system/usr/keychars/generic.kcm.
Change B to
Key B {
Base: ' B ' fallback dpad_center
}
In a non-editable box, log the following
12-23 05:18:09.093 118 118 E ============================: ============ processkey
12-23 05:18:09.094 118 118 E ============================: ============ processkey
12-23 05:18:09.163 118 118 E ============================: ============ processkey
12-23 05:18:09.163 118 118 E ============================: ============ processkey
Note B was not accepted and then called the Dpad_center
In an editable box, B is accepted, log is as follows
============================: ============ Processkey
============================: ============ Processkey
Description does not call fallback
If the modification is as follows
Key B {
Base:fallback Dpad_center
}
In an editable box also to play 4 lines of log, indicating that fallback was called
Android IME intercept key takes precedence over view