title: jQuery Mobile and Android device back button with build.phonegap.com
body: <p>I'm developing an android mobile application using jquery mobile and Phonegap. I'm new to developing android apps using Phonegap. I need to control the function of a back button in android. What I would like is if i'm on a specific page and if I touch the back button there will be a prompt asking if 'do you want to exit the app?'. I could use help on information to go about this.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" charset="UTF-8"/&gt; 
      &lt;link rel="stylesheet" href="themes/theme.min.css" /&gt;
      &lt;link rel="stylesheet" href="css/jquery.mobile.structure-1.3.2.min.css" /&gt;
      &lt;script src="js/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/jquery.mobile-1.3.2.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  document.addEventListener('backbutton', backButtonCallback, false);
  
  function backButtonCallback() {
  navigator.notification.confirm('do you want to exit the app?',confirmCallback);
  }
  function confirmCallback(buttonIndex) {
  if(buttonIndex == 1) {
      navigator.app.exitApp();
      return true;
  }
  else {
      return false;
  }
  }
  &lt;/script&gt;
  
  &lt;/head&gt;
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="hap" version="1.0"&gt;
  
      &lt;name&gt;APP&lt;/name&gt;
      &lt;description&gt;Happy Au Pair&lt;/description&gt;
      &lt;author&gt;Myname&lt;/author&gt;        &lt;gap:platforms&gt;
              &lt;gap:platform name="ios" /&gt;
              &lt;gap:platform name="android" /&gt;
              &lt;gap:platform name="webos" /&gt;
              &lt;gap:platform name="symbian.wrt" /&gt;
              &lt;gap:platform name="blackberry" project="widgets"/&gt;
      &lt;/gap:platforms&gt;
      &lt;gap:plugin name="org.apache.cordova.dialogs" /&gt;
       &lt;icon src="icon.png" /&gt;
      &lt;preference name="phonegap-version" value="3.1.0" /&gt;
  
      &lt;access origin="*" subdomains="true" /&gt;
      &lt;access uri="*" subdomains="true" /&gt;
       &lt;access uri="http://gcccs.org" subdomains="true" /&gt;
      &lt;feature name="http://api.phonegap.com/1.0/network"/&gt;
      &lt;feature name="InAppBrowser"&gt;
  &lt;param name="android-package" value="org.apache.cordova.InAppBrowser" /&gt;
      &lt;/feature&gt;
      &lt;feature name="App"&gt;
      &lt;param name="android-package" value="org.apache.cordova.App" /&gt;
  &lt;/feature&gt;
  
      &lt;preference name="orientation" value="portrait" /&gt;
      &lt;preference name="fullscreen" value="true" /&gt;
      &lt;preference name="target-device" value="universal" /&gt;
  
      &lt;icon src="res/icon/android/icon-36-ldpi.png" gap:platform="android" gap:density="ldpi" /&gt;
  &lt;icon src="res/icon/android/icon-48-mdpi.png" gap:platform="android" gap:density="mdpi" /&gt;
  &lt;icon src="res/icon/android/icon-72-hdpi.png" gap:platform="android" gap:density="hdpi" /&gt;
  &lt;icon src="res/icon/android/icon-96-xhdpi.png" gap:platform="android" gap:density="xhdpi" /&gt;
  
  &lt;gap:splash src="res/screen/android/screen-ldpi-portrait.png"  gap:platform="android" gap:density="ldpi" /&gt;
  &lt;gap:splash src="res/screen/android/screen-mdpi-portrait.png"  gap:platform="android" gap:density="mdpi" /&gt;
  &lt;gap:splash src="res/screen/android/screen-hdpi-portrait.png"  gap:platform="android" gap:density="hdpi" /&gt;
  &lt;gap:splash src="res/screen/android/screen-xhdpi-portrait.png" gap:platform="android" gap:density="xhdpi" /&gt;
  
  &lt;/widget&gt;
  </code></pre>