I am trying to select image from the image gallery of android phone and it runs as excepted in the emulator but when I install it in my galaxy s4, it doesn’t work. 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>
Upload
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);
}
I have used similar code to @mrvamsidhar, for selecting the image from the image. It works fine in the emulator 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?? Any help on this matter will be much appreciated thanks.