I am trying to select image from the image gallery of android phone and it runs as expected in the emulator but when I install it in my galaxy s4 and runit, it doesn't work. I have installed the cordova camera plugin and running cordova 3.5.0.2.4 The code snippet is as below
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);
}
It works fine in the emulator and I can access the image gallery but it doesnt work in the real devices though and whenever I click on the button to select the image, it alerts me 'camera not found' . Does anyone know why it happens?? Is it related to cordova camera plugin?? Or am i doing something wrong? Any help on this matter will be greatly appreciated thanks.