Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use navigator.app.exitApp()?

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()?

like image 369
Hodaya Shalom Avatar asked Dec 02 '12 11:12

Hodaya Shalom


1 Answers

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(); 
    }
}
like image 190
Mayur Birari Avatar answered Nov 14 '22 19:11

Mayur Birari