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

Covering the Camera API


The Camera API is what permits us to capture images and to access the user's saved photo library. While we'll cover a lot of the API in this task, if you want to see the most up-to-date documentation for it, visit https://github.com/apache/cordova-plugin-camera/blob/dev/doc/index.md.

Getting ready

Before continuing, be sure to add the camera plugin to your project:

cordova plugin add org.apache.cordova.camera

Getting on with it

Taking a picture is easy, especially when compared with prior APIs we've dealt with. You can simply use this:

navigator.camera.getPicture ( success, error [, options] );

The Camera API will then open in the device and the user can take a picture. Once they are done and approve the picture as taken, the success function will be called with the image. If an error occurs (or the user rejects the image), the error function will be called.

The options parameter is a dictionary that consists of several properties that control the image source (the camera...