一切都在标题中,我通过Camera.getPicture方法访问相机,我可以选择一张照片或拍摄一张照片,但当我访问图片库或相机拍摄照片时,我的错误回调被触发,因此我无法获取图片的URI。它没有使我的应用崩溃,我仍然可以使用它。我尝试使用android的“前景摄像头插件”,但每次都会触发错误回调。
我收到一条错误消息:"07-09 18:33:55.728: D/CordovaLog(10038):error :Camera Canced.“
我正在用三星的Galaxy S2测试我的应用程序,然而,当我用Galaxy Tab10测试它时,一切都很好,但我需要让它在移动设备上运行。
我使用的是Cordova 2.7.0和AngularJS。
编辑:相关错误信息:
07-09 18:47:47.183: D/DroidGap(11126): Paused the application!
07-09 18:47:47.183: D/CordovaWebView(11126): Handle the pause
07-09 18:47:47.183: D/DroidGap(11126): Incoming Result
07-09 18:47:47.183: D/DroidGap(11126): Request code = 18
07-09 18:47:47.183: D/DroidGap(11126): We have a callback to send this result to
07-09 18:47:47.183: D/DroidGap(11126): Resuming the App
07-09 18:47:47.203: D/DroidGap(11126): Paused the application!
07-09 18:47:47.203: D/CordovaWebView(11126): Handle the pause
07-09 18:47:47.213: W/CordovaPlugin(11126): Attempted to send a second callback for ID: Camera169951334
07-09 18:47:47.213: W/CordovaPlugin(11126): Result was: "No result"
07-09 18:33:55.728: D/CordovaLog(10038): error :Camera cancelledJavaScript:
$scope.chooseImage = function() {
navigator.notification.confirm('Ajoutez une photo', function (buttonIndex) {
$scope.getImage(buttonIndex);
},'PokeMe',["Prendre","Choisir"])
};
$scope.getImage = function(buttonIndex) {
var sourceType = buttonIndex == 1 ? Camera.PictureSourceType.CAMERA : Camera.PictureSourceType.PHOTOLIBRARY;
var options = {
quality: 80,
destinationType : Camera.DestinationType.FILE_URI,
sourceType: sourceType,
encodingType: Camera.EncodingType.JPEG,
cameraDirection: Camera.Direction.BACK,
correctOrientation: true
}
navigator.camera.getPicture(function (imgData) {
window.safeApply($scope, function() {
console.log('success'+imgData);
$scope.profileSrc = imgData;
});
}, function (msg){console.log('error :'+msg)}, options); //This callback is fired
};
}HTML:
<div ng-click="chooseImage()" style='margin-top: 30px;margin-bottom: 30px;' id="yellow_btn" ><p><img src='img/upload.png' />Ajoutez une photo</p></div>发布于 2013-07-10 00:56:11
检查你的AndroidManifest.xml文件,确保你的应用程序的摄像头权限存在:
<uses-permission android:name="android.permission.CAMERA" />如果它不在那里,那么它可能会在你的Galaxy Tab上运行,因为旧版本的安卓系统对应用程序的默认功能更为宽松,但你的S2有较新版本的安卓系统,需要明确的权限才能访问摄像头。
编辑:基于此Google Groups discussion,尝试更改行:
android:launchMode="singleInstance"至
android:launchMode="singleTask"在config.xml中
发布于 2013-11-06 21:49:25
在我的情况下,我实际上是打电话给..
This.callbackContext.sendPluginResult(新错误(PluginResult.Status.ERROR,“糟糕,错误:()"));
从execute()返回时;
除了打电话..。
this.callbackContext.success(your_data);
从execute();中删除第一个调用。
https://stackoverflow.com/questions/17553727
复制相似问题