title: cordova events not working, what wrong am i doing
body: <p>My code below, its not working on my android device, I wish to achieve this -</p>
  
  <ol>
  <li>when my app is about to minimize, it should say <code>alert("bye");</code></li>
  <li>when i again open my app (provided its running in background) , <code>alert("resume");</code></li>
  <li>when opened for the first time, <code>alert("device ready");</code></li>
  </ol>
  
  <p>I thought i have done everything right, but not sure where i am wrong. Please help</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// example.js file
  // Wait for device API libraries to load
  //
  function onLoad() {
      document.addEventListener("deviceready", onDeviceReady, false);
  }
  
  // device APIs are available
  //
  function onDeviceReady() {
      alert("device ready");
      document.addEventListener("pause", onPause, false);
      document.addEventListener("resume", onResume, false);
      document.addEventListener("menubutton", onMenuKeyDown, false);
      document.addEventListener("backbutton", onBackKeyDown, false);
      // Add similar listeners for other events
  }
  
  
  
  function onPause() {
      // Handle the pause event
      alert("pause");
  }
  
  function onResume() {
      // Handle the resume event
      alert("resume");
  }
  
  function onMenuKeyDown() {
      // Handle the menubutton event
      alert("menu key down");
  }
  
  
  function onBackKeyDown() {
      // Handle the onBackKeyDown event
      alert("back key down");
  }
  
  // Add similar event handlers for other events</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
      &lt;title&gt;Device Ready Example&lt;/title&gt;
  
      &lt;script type="text/javascript" charset="utf-8" src="cordova.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" charset="utf-8" src="index.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body onload="onLoad()"&gt;
      &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>