我使用的科尔多瓦3.4带摄像头的插件(https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md)
I am using Cordova 3.4 with Camera Plugin (https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md)
当我打电话
navigator.camera.getPicture(onSuccess, onFail, {
quality: 75,
destinationType: window.Camera.DestinationType.FILE_URI,
sourceType: window.Camera.PictureSourceType.CAMERA,
//allowEdit: true,
//cameraDirection: window.Camera.Direction.FRONT,
//encodingType: window.Camera.EncodingType.JPEG,
//targetWidth: 100,
//targetHeight: 100,
//popoverOptions: window.CameraPopoverOptions,
saveToPhotoAlbum: true
});
function onSuccess(imageData) {
alert(imageData);
}
function onFail(message) {
alert('Failed because: ' + message);
}
这code适用于Windows Phone的8.1,但为Android 4.3(果冻豆)不起作用。当我踏入在eclipse code,我可以看到它成功保存照片的Android temp目录下,但不调用JavaScript的成功或失败事件的完整的,这就是为什么我不能在Android上获取的图像。
this code works for Windows Phone 8.1 but does not work for Android 4.3 (Jelly Bean). When I step into code in eclipse I can see that it successfully saves photo under android temp directory but does not call JavaScript success or fail event on complete, that's why I cannot get image on android.
我都试过的Galaxy Note 2实际设备和仿真器,并没有要求的onSuccess两个。
I both tried on Galaxy Note 2 real device and emulator and did not call onSuccess on both.
是否有任何已知问题或解决方法这个问题?
Is there any known issues or workaround for this problem?
如果这是行不通的,让我为您介绍这些选项。他们正在为部署在4.2.2(杰利贝恩)Android和4.4.2(奇巧)。
If this isn't working, let me suggest these options. They're working as deployed on 4.2.2 (Jellybean) android and 4.4.2 (Kitkat).
navigator.camera.getPicture(this.onPhotoDataSuccess, this.onFail, {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA
});
//读取和追加DOM
//reading and appending the DOM
onPhotoDataSuccess(imageData) {
var smallImage = document.getElementById('smallImage');
smallImage.style.display = 'block';
smallImage.src = "data:image/jpeg;base64," + imageData;
}
这将返回一个base64连接codeD映像。
This will return a base64 encoded image.
上一篇:抽屉式导航栏MainActivity的onCreate前onNavigationDrawerItemSelected叫什么名字?叫什么名字、抽屉式、onCreate、MainActivity
下一篇:拒绝权限:访问服务ComponentInfo {...}从PID = -1权限、ComponentInfo、PID