Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • List of phonegap addEventListener

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 396
    Comment on it

    In phonegap application there are many events that can be used and for these events the application code may add a listeners.

    Lets take an example to evaluate this thing:

    HTML:

    <html>
        <head>
        <title>Events Example</title>
    
        <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
        </head>
        <body onload="onLoad()">
        </body>
    </html>

    JS:

    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }
    
    
    function onDeviceReady() {
        document.addEventListener("pause", onPause, false);
        document.addEventListener("resume", onResume, false);
        document.addEventListener("menubutton", onMenuKeyDown, false);
    }
    
    function onPause() {
        // this will fire pause event
    }
    
    function onResume() {
        // this will fire resume event
    }
    
    function onMenuKeyDown() {
        // this will fire menubutton event
    }
    

    Please note that you can use document.addEventListener in your application once the deviceready.


    Here is the list of events:

    1. deviceready
    2. pause                     
    3. resume                     
    4. backbutton                     
    5. menubutton                     
    6. searchbutton                     
    7. startcallbutton                     
    8. endcallbutton                     
    9. volumedownbutton                     
    10. volumeupbutton

    Also the device ready event fire only when cordova is loaded.

    document.addEventListener("deviceready", onDeviceReady, false);

    Hope this blog makes you clear about the events in phonegap.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: