public class ChiceScanGunActivity extends Activity{
@Override
protected boolean onKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
int keyCode = event.getKeyCode();
if (keyCode <= 6) {
return false;
}
if (mScanGun.isMaybeScanning(keyCode, event)) {
return true;
}
}
return true;
}
@Override
public void onCreate() {
super.onCreate();
//TODO
mScanGun = new ScanGun(new ScanGunCallBack() {
@Override
public void onScanFinish(String scanResult) {
if (!TextUtils.isEmpty(scanResult)) {
Toast.makeText(DetectionService.this.getBaseContext(),
"无界面监听扫描枪数据:" + scanResult, Toast.LENGTH_SHORT).show();
}
}
});
mScanGun.setMaxKeysInterval(50);
}
}
1