tidev / ti.barcode

QR and Barcode Scanner
Other
67 stars 90 forks source link

Android back button issue on Pie #102

Open hiteshmanawat opened 5 years ago

hiteshmanawat commented 5 years ago

When the barcode overlay screen is opened and I click on the android back button it closes the screen as well as it calls the android: back event of the previous window screen because of that it close the current screen from where the barcode is called as well as the overlay barcode screen. It shifts to 1 step back of android button on the window. It works fine on other Android OS version lower the PIE. But especially on Pie, it seems to happen.

m1ga commented 5 years ago

not sure if that is a problem with ti.barcode. You could check in your android:back event if the barcode scanner is open and then prevent it from closing.

checknique commented 2 years ago

I just ran into this problem. Pressing the Android OS back button closed both the overlay and bubbled up and closed the app. May not be the best way to solve this, but here's what I did:

//In alloy.js, set a global var: Alloy.Globals.barcodeGoback = '';

//In index.js, button's func that calls up Ti.Barcode scanner: function callCamera() { Alloy.Globals.barcodeGoback = '1'; //change var to 1 to signal it needs closed Barcode.capture({ animate: true, overlay: $.overlay, showCancel: false, showRectangle: false, keepOpen: false, preventRotation: true, acceptedFormats: [ Barcode.FORMAT_QR_CODE, Barcode.FORMAT_DATA_MATRIX ] });

//In index.js, add an event listener for androidback that closes only the overlay: $.appWindow.addEventListener('androidback', function(){ if (Alloy.Globals.barcodeGoback == 1) { $.yourView.remove($.overlay); //remove the overlay Alloy.Globals.barcodeGoback = '0'; //change the global var back to 0 } else if.... //add more if needed });