O'Reilly logo

PhoneGap 3.x Mobile Application Development HOTSHOT by Kerri Shotts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required