First, add a broadcast to the custom key
Modifying the Interceptkeybeforedispatching method in Phonewindowmanager.java
/frameworks/base/policy/src/com/android/internal/policy/impl/phonewindowmanager.java
@Override Public long interceptkeybeforedispatching (WindowState win, keyevent event, int policyflags) {final Boole
An Keyguardon = Keyguardon ();
Final int keycode = Event.getkeycode ();
Final int repeatcount = Event.getrepeatcount ();
Final int metastate = Event.getmetastate ();
Final int flags = Event.getflags ();
Final Boolean down = event.getaction () = = Keyevent.action_down;
Final Boolean canceled = Event.iscanceled ();
Final Boolean longpress = (Flags & keyevent.flag_long_press)!= 0;
Final Boolean virtualkey = Event.getdeviceid () = = Keycharactermap.virtual_keyboard;
Final String iscitkeytest=systemproperties.get ("Persist.sys.startCitKeyTest");
Add a custom key broadcast----start switch (keycode) {case 135:case 136:case 137:case 139:
{if (repeatcount = = 0) {Intent mykeyintent = new Intent ();
if (down) { Mykeyintent.setaction ("Com.rscja.android.KEY_DOWN");
else {mykeyintent.setaction ("Com.rscja.android.KEY_UP");
} mykeyintent.putextra ("KeyCode", keycode);
Mcontext.sendbroadcastasuser (Mykeyintent, Userhandle.all);
}} break; ///Add custom key to broadcast----end ..............}
Assigning values to the current focus input box by broadcasting
Modifying the OnCreate () method in Inputmethodservice.java
/frameworks/base/core/java/android/inputmethodservice/inputmethodservice.java
Thank you for reading, I hope to help you, thank you for your support for this site!