O'Reilly logo

PhoneGap 3 Beginner's Guide by Giorgio Natili

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

Time for action – accessing the device camera

Get ready to access the device's camera, show the user the captured picture, and allow the user to erase the selection (in iOS only). Refer to the following steps:

  1. Open the command-line tool and create a new PhoneGap project named AccessCamera.
    $ cordova create ~/the/path/to/your/source/camera com.gnstudio.pg.AccessCamera AccessCamera
    
  2. Add the Camera API plugin using the command line.
    $ cordova plugins add https: //git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
    
  3. Using the command-line tool, add the Android and the iOS platforms to the project.
    $ cordova platforms add android
    $ cordova platforms add ios
    
  4. Go to the www folder, open the index.html file, and add a button tag with the id #getPicture ...

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