I have a Motorola TC55, that is equipped with a hardware barcode scanner. What i'd like to do is listen for that button being pressed in my app. I've googled and looked on SO without any luck. Can someone point me to a resource, or suggest how i can get started?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
On the Motorola TC55 the hardware scan button is mapped to the key "BUTTON_L1" by default so this is what you'd listen for like below.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BUTTON_L1 {
//Do something scanner was pressed.
}
}
You can see the key it is mapped to through Settings->Programmable Keys