How to close an application in Phonegap Apache Cordova ?


I recently made a close application button in my Phonegap application.After searching around and reading a lot about it on Stack Overflow, I did mange to create a satisfactory close button mechanism for my android application

With the help of this article you can show a confirm close dialog to a user.

Step 1. Add a close button in HTML

I have added a jquery button. If you are using something else, just make sure that you have included the onclick.

Step 2. Handle the onclick event in Javascript

The showConfirm function shows a dialog box to the user. When the user selects the yes button, the value of buttonIndex turns to 1 and as a result the function is trigerred.


The end result is a native dialog box as above.



sjmach said...

The screenshot is old and also it depends on your Android SDK.

Anonymous said...

Thanks for sharing your knowledge like this.

I would like to invite you to try our latest iteration of "AppGyver steroids" for PhoneGap. I believe you will be able to build apps much faster for your customers than ever before.

Please give it a try and let me know what you think, and let me know if you have any questions; I'd be happy to introduce to to the support team.

These recent write-ups give a little more context:

michael.smith [at]

Follow me:

"We will not be remembered for building cool tools that build crappy apps"

Post a Comment

Written by Sundeep Machado © 2007 - 2018 Sundeep Machado

You can get in touch with him on and Twitter