Reputation: 363
I have android mobile application created with sencha Ext JS framework, JavaScript and Cordova library. This app will only run in the PDA device(Point Mobile PM85) and PDA device have inbuild scanning button function to scan any barcode and return the value.
My issue is with continue scanning function in PDA device on long press inbuild scan button. If we do long press scan button it will scan the barcode and return the data. The data will display in input field. After long press scan button scan function works but it is calling the previous or any active page automatically without calling to the current page.
Scan function calling using the Cordova barcode scan plugin (Cordova-plugin-point-mobile).
I have tried to remove the last page after navigate to current page. But having the same issue. And we can't use the destroy method to remove the last page because in some case we are using the data transfer one page to another page.
Below code are using to scan the barcode-
When page will enter scan function is active for scanning. After press the barcode scan button below code will execute and return the value.
Current page scan function-
function(){
const barcode = function (event) {
if (event.keyCode == '0') { // scan function event code in PDA scan button after press the scan button
const pointMobile = window.cordova.plugins.pointmobile;
pointMobile.scan(
data => {
object = { barcode: data.barcode.trim() };
searchfield.setValue(object.barcode);
},
error => {
console.log('barcode scan error');
},
);
}
}
document.addEventListener("keydown", barcode, false); // Cordova call to scan event listener
}
Last page scan function-
This function auto call without invoking it.
function(){
const barcode = function (event) {
if (event.keyCode == '0') { // scan function event code in PDA scan button after press the scan button
const pointMobile = window.cordova.plugins.pointmobile;
pointMobile.scan(
data => {
object = { barcode: data.barcode.trim() };
searchfield.setValue(object.barcode);
},
error => {
console.log('barcode scan error');
},
);
}
}
document.addEventListener("keydown", barcode, false); // cordova call to scan event listener
}
All the page have same code and same issue.
Kindly help and check why scan function calling to another function without invoking it.
Upvotes: 0
Views: 37