ti.barcode icon indicating copy to clipboard operation
ti.barcode copied to clipboard

Android back button issue on Pie

Open hiteshmanawat opened this issue 6 years ago • 2 comments

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.

hiteshmanawat avatar Jan 29 '19 12:01 hiteshmanawat

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.

m1ga avatar Jan 29 '19 17:01 m1ga

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 });

checknique avatar May 26 '22 04:05 checknique