Time for action – accessing the device camera
Get ready to access the device's camera and show the user the captured picture. Refer to the following steps:
Open the command-line tool and create a new PhoneGap project named
camera
:$ cordova create camera
Change to the directory that is created:
$ cd camera
Using the command-line tool, add the Android and iOS platforms to the project:
$ cordova platforms add android $ cordova platforms add ios
Add the Camera API plugin using the following command line:
$ cordova plugin add cordova-plugin-camera
Go to the
www
folder, open theindex.html
file, and replace the contents with the following code; this code is self-explanatory:<!DOCTYPE html> <html> <head> <script type=”text/javascript” charset=”utf-8” src=”cordova.js”></script> <script type=”text/javascript” charset=”utf-8”> // Wait for device API libraries to load document.addEventListener(“deviceready”, onDeviceReady,false); // device...