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

How to use IndexedDB in HTML5

Posted on 3 years ago

Bhumi

How To Use The HTML5 Notification API

Posted on 1 year ago

Bhumi

What are Lambdas and Closures in PHP?

Posted on 1 year ago

Bhumi