Cordova EventsCordova provides a set of various events for your application. These events are fired by the application, if required. We know that sometimes, we often need to determine when our application enters the device background and when it comes back into the foreground. So, for such tasks, we have event listeners. Here, we define an application code that can add the event listeners. HTML FileJS FileThe following table lists the cordova events and the supported platforms:
devicereadyThis event is fired when the Cordova application is fully loaded. It is an essential event for any of the applications. We need to use this event for getting the information about the device APIs that if they have loaded and are ready to access. The Cordova application provides two code bases i.e., native and JavaScript. A custom image is displayed when the native code loads. However, the DOM loads when JavaScript will load. Once this event gets fired, we can make calls safely to the Cordova APIs. Quick Example pauseThis event gets fired when a native platform is used to run the application into the background. It mainly occurs when a user switched to the other application Quick Example resumeThis event gets fired only when a native platform leaves the application from the background. Quick Example backbuttonWhen a user clicked on the back button, this event is fired. Register an event listener for backbutton event, if you want to override the behaviour of default back-button. Quick Example menubuttonWhen a user clicked on the menu button, this event is fired. To overrides the behaviour of default menu button, need to apply an event handler. Quick Example searchbuttonOn Android platform, this event is fired only when a user clicked on the search button. We need to register an event listener for this event to override the behaviour of default search button. Quick Example startcallbuttonWhen a user clicks on the start call button, then this event is fired. We need to register an event listener for this particular event to override the behavior of default start call. Quick Example endcallbuttonWhen a user clicks on the end call button, this event is fired. To override the behavior of default end call, we can use this event. Quick Example volumedownbuttonWhen a user clicks on the volume down button, this event is fired. We need to register an event listener for this particular event to override the behavior of default volume down. Quick Example volumeupbuttonWhen a user clicks on the volume up button, this event is fired. We need to register an event listener for this particular event to override the behavior of the default volume up. Quick Example activatedThis event is fired only when it occur the Windows Runtime activation. Quick Example Next TopicCordova Hooks |