How to use navigator.app.exitApp () to exit the application in a phone gap?

I have an application created using sencha-touch and phonegap, but I do not know how to add the exit / stop function to exit the application. After searching on Google and other sites, I realized that using navigator.app.exitApp() , but that did not work.

How can i solve this?

Note: I am using - telephone conversation 1.3 - sencha touch 1.1 - Galaxy tab

Thanks in advance

+6
source share
4 answers

Please try the following code, it works fine in my application:

 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(); } } 
+10
source

Put something like this in your HTML file:

 <a href="#" onClick="closeMeNow();" data-role="button">Close App</a> 

This is a link to such a function in your JS file:

 function closeMeNow() { navigator.app.exitApp(); } 

I know that the syntax is more JQM than Sencha, but since the concept is basically the same, you can simply edit where necessary.

+1
source

See this

You need to add a listener event for the lining and bind the function.

It would be nice to upgrade your phonegap / cordova version to the latest build and use the code above.

0
source

This code resembles a charm:

 Ext.Msg.confirm("Close app?.", 'Close app', function (btn) { if (btn == 'yes') { navigator.app.exitApp(); } }); 
0
source

Source: https://habr.com/ru/post/905168/


All Articles