Reputation: 3349
I used following function for the windows mobile app(phonegap) to handle the backbutton navigation function.
function onBackKeyDown() {
var currentPageId = $.mobile.activePage.attr('id');
if(currentPageId == 'contact-us' || currentPageId == 'about-us' || currentPageId == 'location-map' || currentPageId == 'services'){
$.mobile.changePage("index.html", {
transition : "slide",
reverse : true,
changeHash : false
});
}else{
navigator.app.exitApp();
}
}
I wanted to come to the index if the current page is not index. Otherwise exit the app. It seems like navigator.app.exitApp() doesn't work in windows phone 7. Is there any solution for overcome this issue.
Upvotes: 2
Views: 517
Reputation: 1487
This plugin came in handy for me.
http://shinymetilda.github.io/Cordova_Exit_Plugin/
Add the .cs file to your plugin directory.
Add the following code to config.xml
<feature name="AppTerminate">
<param name="wp-package" value="AppTerminate" />
</feature>
write this code instead of navigator.app.exitApp()
cordova.exec(null, null, "AppTerminate", "execute", []);
Upvotes: 1