0
votes

I am very much new to phonegap applications but i am an android developer.I am trying to call camera on a button click in my phonegap application.Following is my html where i am calling take_pic() method of camera.js api javascript.I have included camera.js in body after seeing api example only.

<body>
<label for="hello">Hello World</label>
<br><input type="submit" id="submit" value="Call Camera" onclick="take_pic();">
<script type="text/javascript" charset="utf-8" src="apis/camera.js"></script>
</body>

following is the method of camera.js which is triggered but it throws "Can not read propery 'DATA_URL' of undefined type at file:///android_asset/www/apis/camera.js:45" error .Please guys help me out.let me know if more details are required

function take_pic() {
  navigator.camera.getPicture(onPhotoDataSuccess, function(ex) {
    alert("Camera Error!");
  }, { quality : 30, destinationType: destinationType.DATA_URL });
}
1

1 Answers

0
votes

Did you try the next code? it is in the PhoneGap API examples: PhoneGap example

var pictureSource;   // picture source
var destinationType; // sets the format of returned value

// Wait for device API libraries to load
//
document.addEventListener("deviceready",onDeviceReady,false);

// device APIs are available
//
function onDeviceReady() {
    pictureSource=navigator.camera.PictureSourceType;
    destinationType=navigator.camera.DestinationType;
}

function take_pic() {
    navigator.camera.getPicture(onPhotoDataSuccess, function(ex) {
        alert("Camera Error!");
    }, { quality : 30, destinationType: destinationType.DATA_URL });
}

I think your problem is that the variable "destinationType" is undefined. Did you initialized it properly?