1
votes

I have created an app with Jquery mobile 1.4.4 with PhoneGap.The app have multiple pages (each page in sparate html file).I am calling/navigating each page using

 $.mobile.changePage( "templates/login.html", { transition: "slide", changeHash: false });

When I am using back button in android to goback to previous page it exit the whole app.

I have followed the solutions mentioned here Phonegap Android Back Button - close app with back button on homepage

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

The above solution is not working.How can i handle back page option in android PhoneGap?

1

1 Answers

0
votes

use like this

 if($.mobile.activePage.is('#homepage')){
   e.preventDefault();
   navigator.app.exitApp();
   }
   else {
    history.back();
    return false;
   }