I want to open bar-code scanner using hardware button provided by point device in my application,
please provide technical details with sample
I want to open bar-code scanner using hardware button provided by point device in my application,
please provide technical details with sample
In your Activity:
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (!handleKeyEvent(event)) {
return false;
}
return super.dispatchKeyEvent(event);
}
private boolean handleKeyEvent(KeyEvent event) {
InputDevice device = event.getDevice();
if (device != null) {
if (device.isVirtual()) {
return true;
}
if (event.getAction() == KeyEvent.ACTION_UP) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_CAMERA:
// add your logic here
break;
}
}
return false;
}
return true;
}