Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6989921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:16:40+00:00 2026-05-27T19:16:40+00:00

I am developing a Android app using Jquery Mobile/Phonegap. I have the following code

  • 0

I am developing a Android app using Jquery Mobile/Phonegap. I have the following code to control the phone’s back button:

document.addEventListener("backbutton", backKeyDown, true); 


function backKeyDown() { 
    // Call my back key code here.
    $.mobile.changePage("#homepage", "slideup");
}

This all works fine, but I would like the app to close when pressing the back button on the homepage only, is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:16:40+00:00Added an answer on May 27, 2026 at 7:16 pm

    Update: this has stopped working with a latest Phonegap update (supposedly). Feel free to offer a working solution if you know it.


    Here’s how I do it:

    document.addEventListener("backbutton", function(e){
        if($.mobile.activePage.is('#homepage')){
            /* 
             Event preventDefault/stopPropagation not required as adding backbutton
              listener itself override the default behaviour. Refer below PhoneGap link.
            */
            //e.preventDefault();
            navigator.app.exitApp();
        }
        else {
            navigator.app.backHistory()
        }
    }, false);
    

    For further information, here you can find the related documentation with a full example: http://docs.phonegap.com/en/2.0.0/cordova_events_events.md.html#backbutton

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an app using phonegap for Android. I want this mobile application
I am developing the application using jQuery Mobile 4.1. In my app, I have
I am developing an Android app. I have written my own code for back
I have project where i'm developing an Android App using a lot of existing
I'm in the middle of developing android app using google map. My question is
I am developing an Android App and would like to have a video file
I'm currently developing an Android app, which loads events from a server using JSON
I am developing an Android app (see screenshots). I have a layout that looks
I'm having the following issue developing in android 2.2 (API 8): I have a
I am developing an Android app on my Windows 7 Home PC using Eclipse.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.