检测来自软件或硬件键盘的输入 [英] Detect input from software or hardware keyboard

查看:88
本文介绍了检测来自软件或硬件键盘的输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用必须使用RFID标签阅读器的Android应用程序工作.我将此读取器用作通过OTG线连接到我的microUSB中的额外设备. Android正在将该设备检测为输入键盘.我想知道是否可以通过编程方式检测用户何时使用此阅读器进行输入.因此,基本上,我必须区分来自软键盘或此阅读器的输入.我进行了很多搜索,但找不到解决方案,将不胜感激.非常感谢.

I'm working in an Android app that must use a RFID tag reader. I'm using this reader as an extra device connected in my microUSB with an OTG wire. Android is detecting this device as an input keyboard. I would like to know if I can programatically detect when a user does an input with this reader. So basically I must differenciate the input from my softkeyboard or this reader. I searched a lot but I can't find a solution any help would be so appreciated. Thank you very much.

推荐答案

yourEditText.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            return false;
        }
    });

这将检测您的editText是否正在使用硬件键盘进行编辑.

This will detect if your editText is being editted with a hardware keyboard.

此处所述,这仅对硬件键盘有用,因此,如果您未调用此接口,则意味着editText输入应来自软件键盘.

As stated here this is only useful for hardware keyboard, so in your case if this interface is not called, that means the editText input should come from the software keyboard.

这篇关于检测来自软件或硬件键盘的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆