You can create a simple plugin. Add the ExitApp.css file to your platforms / wp 8 / Plugins folder with:
using System.Windows; namespace WPCordovaClassLib.Cordova.Commands { class ExitApp : BaseCommand { public void execute(string options) { Application.Current.Terminate(); } } }
edit your platforms / wp 8 / config.xml and add to the widget tag:
<feature name="ExitApp"> <param name="wp-package" value="ExitApp" /> </feature>`
then from you javascript call:
cordova.exec(null, null, "ExitApp", "execute", []);
You can use it in combination with the "backbutton" event to close the application when the user clicks on the button on the main page:
function goBack(e){ if(isInMyMainPage()) cordova.exec(null, null, "ExitApp", "execute", []); } document.addEventListener("backbutton", goBack, false)
source share