android系统下怎么广播键盘的输入消息

有时我们希望程序在后台运行时能接收到按键输入消息,我们在底层修改添加广播消息就可以实现这样的功能,具体过程如下所示:

1.在lichee/linux-3.0/include/linux/input.h文件可以查看底层驱动的按键编码
#define KEY_F1 59
#define KEY_F2 60
#define KEY_F3 61
#define KEY_F4 62
#define KEY_F5 63
#define KEY_F6 64
#define KEY_F7 65
#define KEY_F8 66
#define KEY_F9 67
#define KEY_F10 68
2.在android4.0/frameworks/base/core/java/android/view/KeyEvent.java文件可以查看上层驱动的按键编码
/** Key code constant: F1 key. */
public static final int KEYCODE_F1              = 131;
/** Key code constant: F2 key. */
public static final int KEYCODE_F2              = 132;
/** Key code constant: F3 key. */
public static final int KEYCODE_F3              = 133;
/** Key code constant: F4 key. */
public static final int KEYCODE_F4              = 134;
/** Key code constant: F5 key. */
public static final int KEYCODE_F5              = 135;
/** Key code constant: F6 key. */
public static final int KEYCODE_F6              = 136;
/** Key code constant: F7 key. */
public static final int KEYCODE_F7              = 137;
/** Key code constant: F8 key. */
public static final int KEYCODE_F8              = 138;
/** Key code constant: F9 key. */
public static final int KEYCODE_F9              = 139;
/** Key code constant: F10 key. */
public static final int KEYCODE_F10             = 140;
3.在/android4.0/frameworks/base/data/keyboards/Generic.kl文件里面有底层到上层的映射&#

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值