Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Titanium Barcode Scanner issue: multiple success events fired

$
0
0

We are using the [Titanium Barcode Scanner] (https://marketplace.appcelerator.com/apps/4963?restoreSearch=true#!overview) module from the marketplace in one of our apps . We use Titanium SDK 3.3.0.

The issue we are facing is as follows: The first time we open up the window with the scanner, it scans perfectly fine. However, the second time we open up the window with the scanner, it scans the barcode and returns the success event twice. The third time we open up the window, it returns the success event thrice and so on.

We have tried removing the eventlistner for success when we go form one window to another. We have also tried making the barcode object null when we move to another window. We have also tried closing the window which removes it from the memory. But the issue still persists.

This is how we initialize the Barcode:

var BarcodeUsed = require('ti.barcode');
BarcodeUsed.allowRotation = true;
BarcodeUsed.displayedMessage = ' ';
BarcodeUsed.allowMenu = false;
BarcodeUsed.allowInstructions = false;
BarcodeUsed.useLED = false;
 
BarcodeUsed.capture({
        animate : false,
        //overlay : overlay,
        showCancel : true,
        showRectangle : true,
        keepOpen : false,
        acceptedFormats : [BarcodeUsed.FORMAT_CODE_128]
    });
This is how we handle the event listeners
BarcodeUsed.addEventListener('error', function(e) {
    scanResult.text = e.message;
});
 
BarcodeUsed.addEventListener('cancel', function(e) {
    Ti.API.info('Cancel received');
});
 
var i = 0;
BarcodeUsed.addEventListener('success', function(e) {
 
    //i++;
    //alert("Successs ..... " + e.result + "Count : " + i);
 
    Ti.API.info('Success called with barcode: ' + e.result);
if(e.result == prevBarcode){
            alert('same bar code....');
        } else {
            prevBarcode = e.result;
    success1(e.result);
}
 
});
We have used the eventlisters from the examples and made a few modifications for the functionality.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>