I have used following code to exit from application. For first time it works perfectly. But when I opened some next screens and then came back to screen where I wanted to close my application, it fails to close application.
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
function onLoad()
{
document.addEventListener("deviceready", onDeviceReady, false);
//alert("Load");
}
function onDeviceReady()
{
document.addEventListener("backbutton", onBackKeyDown, true);
// alert("Device Ready");
}
function onBackKeyDown()
{
navigator.app.exitApp();
}
</script>
Please suggest something which will work ....