Reputation: 4417
I have an application built in html5 and phonegap for android, by pressing the exit button I call the following function(JavaScript):
function close_window() {
if (confirm("Exit?")) {
navigator.app.exitApp()
}
}
Window with the message "Exit?" appear, but the application does not close when you click OK, how can we close it?
Is this the way to use navigator.app.exitApp()?
Upvotes: 5
Views: 11170
Reputation: 1
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
checkConnection();
}
function checkConnection() {
var networkState = navigator.connection.type;
if(navigator.connection.type == Connection.NONE) {
alert("No network connection");
}
}
Upvotes: 0
Reputation: 5835
I think your missing with call of confirm
notification.
Please try following code, it is working fine in my app:
document.addEventListener("exitButton", function(){
navigator.notification.confirm(
'Do you want to quit',
onConfirmQuit,
'QUIT TITLE',
'OK,Cancel'
);
}, true);
function onConfirmQuit(button){
if(button == "1"){
navigator.app.exitApp();
}
}
Upvotes: 10