2

I have an application built in html5 and wrapped in phoneGap, by pressing the exit button the following function occurs:

function close_window() {
    if (confirm("Exit?")) {
        navigator.app.exitApp();
    }
}

It does not work..

On clicking the button the function close_window() occurs, 'but navigator.app.exitApp();' line not works.

I think it's because there is no child named app for navigator.. (I tested it in console)

Are there other ways to close an application?

Hodaya Shalom
  • 4,327
  • 12
  • 57
  • 111
  • 1
    which phonegap version do you use ? – Zakaria Dec 03 '12 at 11:40
  • 3
    had the same problem even with the newest version available... at the end, I've abandoned the idea, as Android/iPhone users do not close their apps and the behaviour is considered a non-standard and thus not very recommended for app devs – Zathrus Writer Dec 03 '12 at 11:44
  • 1
    There are many applications with exit button .. Even if users on Android \ iPhone does not close the application, there is a possibility ... – Hodaya Shalom Dec 03 '12 at 11:47
  • 1
    phonegap --> newest version – Hodaya Shalom Dec 03 '12 at 11:50
  • 1
    Which newest version? if it's the one from github.com/apache/incubator-cordova-android (which most code links still point to and is the top result in google), it is no longer the latest version and contains a bug in the app plugin. The actual latest code is at http://github.com/apache/cordova-android – Tom Clarkson Dec 03 '12 at 12:16
  • What do you see in "adb logcat" when you click your exit button? – Simon MacDonald Dec 03 '12 at 16:49

3 Answers3

3

Please be aware that exitApp function works only on android devices. Which version of phonegap do you use?

Idan Gozlan
  • 3,173
  • 3
  • 30
  • 47
0

Finally the problem was solved ..

Exit application works by the function write-up question.

I have no idea what I changed that it works, but it works!!

Thanks for the help ..

:]

Hodaya Shalom
  • 4,327
  • 12
  • 57
  • 111
0

you could use BackButton.exitApp();