0

我对phonegap应用程序非常陌生,但我是一名android开发人员。我试图在我的phonegap应用程序中单击按钮调用相机。以下是我的html,我在其中调用camera.js api javascript.I的take_pic()方法仅在查看 api 示例后将 camera.js 包含在正文中。

<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>

以下是触发的camera.js方法,但它抛出“Can not readpropery 'DATA_URL' of undefined type at file:///android_asset/www/apis/camera.js:45”错误。请大家帮帮我.让我知道是否需要更多详细信息

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

1 回答 1

0

你试过下一个代码吗?它在 PhoneGap API 示例中:PhoneGap 示例

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 });
}

我认为您的问题是变量“destinationType”未定义。您是否正确初始化它?

于 2013-06-24T06:51:46.550 回答