我正试图用我的画廊用cordova相机拍照但是它不起作用,当我选择一张照片并返回我的应用程序时,它会让我空了,这是我的代码:
var options = {
quality: 75,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
mediaType: 2,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function (imageURI) {
//Error ocurrs here, imageURL always is empty. IT OCCURS ONLY IN ANDROID VERSION 4.
$scope.profileImageUrl = imageURI;
$scope.newImage = imageURI;
$scope.newImageName = imageURI.split("/").pop();
var extension = $scope.newImageName.split(".").pop();
if(extension == "png" || extension == "jpg" || extension == "jpeg") {
if(ionic.Platform.isAndroid()) {
/* Managing the path of the file in android */
if(imageURI.substring(0,7) != "file://") {
imageURI = "file://" + imageURI;
}
}
if (ionic.Platform.isIOS()) {
/* Managing the path of the file in iOS */
}
window.resolveLocalFileSystemURL(imageURI, function(fileEntry) {
fileEntry.file(function(myFile) {
$scope.fileToUploadMime = myFile.type;
$scope.uploadProfile();
}, function(error) {
console.log("This file doesn't have a Type " + error);
});
}, function(error) {
console.log("Could not resolve File Path" + error);
});
} else {
alert("Only images can be uploaded. Please select an image");
}
}, function (err) {
// An error occured. Show a message to the user
console.log(err);
});
$ cordovaCamera.getPicture(options)开头的错误.then(function(imageURI),imageURL总是空的。仅在安卓版本4中发生。