O'Reilly logo

PhoneGap 4 Mobile Application Development Cookbook by Zainul Setyo Pamungkas

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

Loading a photograph from the device camera roll/library

Different devices will store saved photographs in different locations, typically in either a photo library or a saved photo album. The camera plugin API gives developers the ability to select or specify from which location an image should be retrieved.

How to do it...

We must use the getPicture method, available from the Camera object, to either select an image from the device library, or capture a new image directly from the camera:

  1. Firstly, create a new PhoneGap project named cameraroll by running this command:
    phonegap create cameraroll com.myapp.cameraroll cameraroll
    
  2. Add the devices platform. You can choose to use Android, iOS, or both:
    cordova platform add ios
    cordova platform add android ...

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