In my app, QR code scanner functions as intent to next page. Now the problem is whenever a QR code appears in front of my camera, it will keep scanning and open many many same pages. ( sry, my English is not good, hope u guys can understand the situation).
I wish it only scan one time and only open one page for me.
here is my code:
barcodeDetector.setProcessor(new Detector.Processor<Barcode>() {
@Override
public void release() {
}
@Override
public void receiveDetections(Detector.Detections<Barcode> detections) {
final SparseArray<Barcode> qrcodes = detections.getDetectedItems();
if(qrcodes.size() != 0)
{
txtResult.post(new Runnable() {
@Override
public void run() {
//Create vibrate
Vibrator vibrator = (Vibrator)getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(1000);
txtResult.setText(qrcodes.valueAt(0).displayValue);
Intent intent = new Intent(User.this,Menu.class);
startActivity(intent);
}
});
}
}
});
Can anyone help me to fix it?