Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android back button issue on Pie #102

Open
hiteshmanawat opened this issue Jan 29, 2019 · 2 comments
Open

Android back button issue on Pie #102

hiteshmanawat opened this issue Jan 29, 2019 · 2 comments

Comments

@hiteshmanawat
Copy link

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
Copy link
Contributor

m1ga commented Jan 29, 2019

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants