title: android phonegap handle back button not working
body: <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;PhoneGap Back Button Example&lt;/title&gt;
  
      &lt;script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" charset="utf-8"&gt;
  
      // Call onDeviceReady when PhoneGap is loaded.
      //
      // At this point, the document has loaded but phonegap-1.2.0.js has not.
      // When PhoneGap is loaded and talking with the native device,
      // it will call the event `deviceready`.
      //
      function onLoad() {
          document.addEventListener("deviceready", onDeviceReady, false);
      }
  
      // PhoneGap is loaded and it is now safe to call PhoneGap methods
      //
      function onDeviceReady() {
          // Register the event listener
          document.addEventListener("backbutton", onBackKeyDown, false);
      }
  
      // Handle the back button
      //
      function onBackKeyDown() {alert("back button pressed");
      }
  
      &lt;/script&gt;
    &lt;/head&gt;
    &lt;body onload="onLoad()"&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I want to ask if user want to exit from my app, when it click on back button.</p>
  
  <p>I read this example from <a href="http://docs.phonegap.com/en/1.2.0/phonegap_events_events.md.html#backbutton" rel="nofollow">http://docs.phonegap.com/en/1.2.0/phonegap_events_events.md.html#backbutton</a>
  but it is not working...</p>
  
  <p>How can I do to do it?</p>
  
  <p>I SET SOME ALERT IN ONDEVICEREADY FUNCTION, AND I HAVE SEEN THAT IS NEVER FIRED THIS METHOD....SO THE EVENTLISTENERE DEVICEREADY IS NEVER FIRED...WHY?????
  Thanks a lot.</p>