Book Image

Phonegap Essentials

By : Ivan Turkovic
Book Image

Phonegap Essentials

By: Ivan Turkovic

Overview of this book

Table of Contents (15 chapters)

Core PhoneGap events


The latest version of PhoneGap doesn't come with any plugins installed by default so we can completely customize it for our needs; however, it does still come with a few events that are useful for making an initial hybrid mobile application. These basics are needed for properly managing the workflow of the application. We will examine the events that all major platforms support.

The deviceready event

This event is a must-have if you want to be able to use PhoneGap's functionality or any other plugin. The deviceready event is invoked when PhoneGap and all related resources are loaded and ready to be used.

Let's have a look at the example code:

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    // Now safe to use PhoneGap's APIs
}

The pause event

The pause event is triggered when the native platform puts the application into the background, for various reasons such as closing the application to go into the home screen or switching...