Results 1 to 2 of 2

Thread: android cordova 2.2.0 backbutton and on device ready not fired

  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    17
    Answers
    1

    Default Answered: android cordova 2.2.0 backbutton and on device ready not fired

    Hi, this is my code:
    I am developing with Android 4.2.
    The problem is that ondeviceready is never fired and so also backbutton event is not handled.
    I am using the example of documentation: http://docs.phonegap.com/en/2.2.0/co...tml#backbutton

    Code:
    <!DOCTYPE html><html>
      <head>
        <title>Cordova Back Button Example</title>
    
    
        <script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script>
        <script type="text/javascript" charset="utf-8">
    
    
        // Call onDeviceReady when Cordova is loaded.
        //
        // At this point, the document has loaded but cordova-2.2.0.js has not.
        // When Cordova is loaded and talking with the native device,
        // it will call the event `deviceready`.
        //
        function onLoad() { alert("onload");
            document.addEventListener("deviceready", onDeviceReady, true);
        }
    
    
        // Cordova is loaded and it is now safe to call Cordova methods
        //
        function onDeviceReady() { alert("device ready start");
            // Register the event listener
            document.addEventListener("backbutton", onBackKeyDown, false);
            alert("device ready stop");
        }
    
    
        // Handle the back button
        //
        function onBackKeyDown() { 
            alert("back button clicked");
        }
    
    
        </script>
      </head>
      <body onload="onLoad()">
      </body>
    </html>
    What I am doing wrong?
    Thank you.

  2. This questions is purely about Cordova and nothing with Sencha Touch.

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449
    Answers
    3997

    Default

    This questions is purely about Cordova and nothing with Sencha Touch.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •