Ana*_*KRI 13 android barcode barcode-scanner
我正试图通过我的Android 3.2平板电脑处理条形码扫描仪USB的价值,扫描仪在操作系统中成功运行,但我希望在没有编辑文本的情况下获得程序中的价值,usbmanager主机和附件没有列出它与通过USB连接设备.
大多数插入式条形码扫描仪(我见过)都是HID配置文件设备,因此无论它们插入什么,都应该将它们视为键盘.我想这就是为什么它们没有出现在USB主机API附件列表中.您应该能够通过覆盖Activity.onKeyDown(int keycode,KeyEvent ke)以与Activity中的键盘相同的方式从它们获取原始输入
您的活动中有类似的事情:
@Override
protected boolean onKeyDown(int keyCode, KeyEvent event) {
Log.i("TAG", ""+ keyCode);
//I think you'll have to manually check for the digits and do what you want with them.
//Perhaps store them in a String until an Enter event comes in (barcode scanners i've used can be configured to send an enter keystroke after the code)
return true;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9164 次 |
最近记录: |