Back to Top

How to exit from Android application when press Back button?

To exit from Android application on Back button

Here is the quick article about to explain how to exit from the android application when user press back button.

Well, you guys know that most Android applications do not provide an “Exit” or “Quit” button.Back Button in android devices manages history of the previous page. It’s a way to get back to the previous page but sometimes in the big app, it create issue especially when maintain value using session.

So, Here is the easiest way to convert back button to exit from the app.Let’s see the function:

The simple one core function is used to exit from android from an app and it will close an app.

Must Read:

Save Image/File into sd card in Android using PhoneGap
To setup SQLite for Android-Phonegap application
Display Text Format Proper in IPHONE+ANDROID

As always, thanks for reading. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Comments (2)

  1. Suraj Sharma says:

    Nice example! Saved my day, thanks!

  2. following codes are working great

    function onDeviceReady() {
    document.addEventListener(“backbutton”, onBackKeyDown, false);
    }
    function onBackKeyDown() {
    navigator.app.exitApp();
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

An Introduction to Gulp JS

Posted on 7 years ago

Bhumi

Custom Directives in Angular JS

Posted on 9 years ago

Bhumi

How to Paginate WordPress Taxonomy?

Posted on 11 years ago

Bhumi

How to install zend framework on wamp

Posted on 11 years ago

Bhumi