Book Image

PhoneGap 3.x Mobile Application Development HOTSHOT

By : Kerri Shotts
Book Image

PhoneGap 3.x Mobile Application Development HOTSHOT

By: Kerri Shotts

Overview of this book

<p>PhoneGap allows you to use your existing knowledge of HTML, CSS, and JavaScript to create useful and exciting mobile applications.<br /><br />This book will present you with 12 exciting projects that will introduce you to the dynamic world of app development in PhoneGap. Starting with their design and following through to their completion, you will develop real-world mobile applications. Each app uses a combination of core PhoneGap technologies, plugins, and various frameworks covering the necessary concepts you can use to create many more great apps for mobile devices.</p>
Table of Contents (21 chapters)
PhoneGap 3.x Mobile Application Development HOTSHOT
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Handling device events


So far, we haven't handled various application and device events, but most apps need to support these before they are deployed to production. We've already dealt a little with one particular event (the back button event), but there are many more events that your app may need to know.

Getting ready

The documentation for all these events is located at http://cordova.apache.org/docs/en/edge/cordova_events_events.md.html#Events. We will cover most of the events in detail, but there are additional events that we won't cover and you might want to check out.

There are two plugins that need to be added if you want to respond to the battery and network information events:

cordova plugin add org.apache.cordova.battery-status
cordova plugin add org.apache.cordova.network-information

Getting on with it

Let's add support for event handling by editing www/js/app/main.js. First, we'll add some boilerplate code at the top of APP.start, which adds listeners for the events we care about,...