我正在尝试从Android手机的图片库中选择图像并且它在模拟器中按预期运行但是当我在我的galaxy s4和runit中安装它时,它不起作用。我已经安装了cordova相机插件并运行了cordova 3.5.0.2.4代码片段如下
upload.html
<button class="button-positive button-block button" ng-click="PhotoLibrary()">Select Picture <i class="ion-android-image"></i></button>
<div class="card">
<div class="item item-image">
<div class="row">
<div class="col">
<img id="smallimage" size="10" />
</div>
</div>
</div>
</div>
<button ng-click="UploadPicture()" class="button-positive button-block button">Upload<i class="ion-paper-airplane margin"></i></button>
Controller.js
$scope.PhotoLibrary = function (){
$scope.image = document.getElementById('smallimage');
if (navigator.camera){
navigator.camera.getPicture( photoSuccess, photoError,
{ quality: 50,
sourceType: navigator.camera.PictureSourceType.SAVEDPHOTOALBUM,
destinationType: navigator.camera.DestinationType.FILE_URI
}
);
} else {
alert('camera not found');
}
};
function photoSuccess(imageURI) {
if (imageURI.substring(0,21)=="content://com.android") {
var photo_split=imageURI.split("%3A");
imageURI="content://media/external/images/media/"+photo_split[1];
}
$scope.imageURI = imageURI
$scope.image.src = $scope.imageURI;
$scope.apply();
}
function photoError(message) {
alert('Failed because: ' + message);
}
它在模拟器中运行良好,我可以访问图像库,但它在真实设备中不起作用,每当我点击按钮选择图像时,它会提醒我'未找到相机'。有谁知道它为什么会发生?它与cordova相机插件有关吗?或者我做错了什么?非常感谢任何有关此事的帮助。