Android H/W Back Button causing app refresh rather than going back


#1

I’ve noticed recently that the Android back button in my Cordova mobile app is not going back but instead refreshing my app and causing it to go back to the landing page. Expected result is to simply go back one page using navigator.app.backHistory(). Any idea if something changed in recent versions?

Here’s the code I use:

document.addEventListener("backbutton", function(event) {
    if ($.mobile.activePage.attr('id') === "landingPage") {
        if(navigator.app) {
            navigator.app.exitApp();
        } else if(navigator.device) {
            navigator.device.exitApp();
        }
    } else {
        //also tried: window.history.go(-1);
        navigator.app.backHistory();
    }
}, false);