Book Image

PhoneGap 4 Mobile Application Development Cookbook

Book Image

PhoneGap 4 Mobile Application Development Cookbook

Overview of this book

Table of Contents (19 chapters)
PhoneGap 4 Mobile Application Development Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

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
    
  3. Add the media and file-transfer plugins by running the following commands:

    cordova plugin add cordova-plugin-media
    cordova plugin add cordova-plugin-file-transfer
    
  4. Open www/index.html. Let's clean up the unnecessary elements. We will use jQuery Mobile...