publicclassChiceScanGunActivityextendsActivity{@OverrideprotectedbooleanonKeyEvent(KeyEventevent){if(event.getAction()==KeyEvent.ACTION_DOWN){intkeyCode=event.getKeyCode();if(keyCode<=6){returnfalse;}if(mScanGun.isMaybeScanning(keyCode,event)){returntrue;}}returntrue;}@OverridepublicvoidonCreate(){super.onCreate();//TODOmScanGun=newScanGun(newScanGunCallBack(){@OverridepublicvoidonScanFinish(StringscanResult){if(!TextUtils.isEmpty(scanResult)){Toast.makeText(DetectionService.this.getBaseContext(),"无界面监听扫描枪数据:"+scanResult,Toast.LENGTH_SHORT).show();}}});mScanGun.setMaxKeysInterval(50);}}
1