0

我正在使用 PhonGap API 拍摄照片并将其显示在应用程序中。在模拟器中一切正常(在 chrome 中使用 Ripple 扩展),但在我的手机或平板电脑(都是 android)上不起作用。任何人有任何想法为什么?

编辑:我现在已经确定它正在拍摄并返回照片,它正在创建画布,它只是由于某种原因没有将图像绘制到画布上。

编辑 2:阅读此内容后现已解决:如何使用 Phonegap 将图像加载到 HTML5 画布上。后来的功能不起作用。. . 但就我而言,问题似乎不是权限。

// Called by 'Take Photo' button
function takePhoto() {
  // Take picture using device camera and retrieve image as base64-encoded string. If      
  //camera unavailable it will offer the option to retrieve a file
  navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
  destinationType: Camera.DestinationType.DATA_URL } );
}


// Displays the image on the screen   
function onSuccess (imageData) {   

alert("Hello " + imageData.length); //added this to check if anything was making it to     
///this point

    var image = document.getElementById("image");
    image.src = imageData;
    var c=document.getElementById("myCanvas");
    var ctx=c.getContext("2d");        
    ctx.drawImage(image,0,0,c.width,c.height);        
}


function onFail(message) {
  alert("Failed because: " + message);
}
4

1 回答 1

0
    Paste this on Andorid confing.xml

    <feature name="http://api.phonegap.com/1.0/device" />
    <feature name="http://api.phonegap.com/1.0/battery"/>
    <feature name="http://api.phonegap.com/1.0/camera"/>
    <feature name="http://api.phonegap.com/1.0/contacts"/>
    <feature name="http://api.phonegap.com/1.0/file"/>
    <feature name="http://api.phonegap.com/1.0/geolocation"/>
    <feature name="http://api.phonegap.com/1.0/media"/>
    <feature name="http://api.phonegap.com/1.0/network"/>
    <feature name="http://api.phonegap.com/1.0/notification"/>

    Paste this on AndroidManifest.xml 

    uses-feature android:name="android.hardware.camera" android:required="false"/>
    <uses-sdk android:minSdkVersion="7"/>
    <activity  android:configChanges="orientation|keyboardHidden" />
            <uses-permission android:name="android.permission.CAMERA" />
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
            <permission android:name="android.permission.ACCESS_NETWORK_STATE" />
于 2013-08-16T12:49:03.477 回答