一、给自定义按键添加广播
修改PhoneWindowManager.java中的interceptKeyBeforeDispatching方法
/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@Override public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) { final boolean 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"); //添加自定义按键广播----开始 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; } //添加自定义按键广播----结束 …… …… …… …… }
二、通过广播给当前焦点输入框赋值
修改InputMethodService.java中的onCreate()方法
/frameworks/base/core/java/android/inputmethodservice/InputMethodService.java
感谢阅读,希望能帮助到大家,谢谢大家对本站的 支持!
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索android
, 广播
添加广播
js为input输入框赋值、按键精灵输入框赋值、js给输入框赋值、给输入框赋值、jquery给输入框赋值,以便于您获取更多的相关知识。
时间: 2024-11-10 08:13:46