0
votes

I'm developing an application for Android using phonegap, I have to push back button twice for the app to exit, is this phonegap default behavior? I can add a listener to backbutton and force the app to exit from first push to backbutton as a workaround but would this solve it ?

1
Hi Venddel, did you get any solution for your issue. I am facing the same problem. Not able to find a solution. Need some helpPrals
check the comment below, it solved it.Vanddel

1 Answers

1
votes

No, this is no normal behaviour. The backbutton will be available when deviceready event was fired. E.g.

function onDeviceReady(){
    document.addEventListener("backbutton", function(e){
       if($.mobile.activePage.is('#homepage')){
           e.preventDefault();
           navigator.app.exitApp();
       }
       else {
           navigator.app.backHistory()
       }
    }, false);
}

backbutton http://docs.phonegap.com/en/edge/cordova_events_events.md.html#backbutton deviceready http://docs.phonegap.com/en/edge/cordova_events_events.md.html#deviceready