My development environment is mac osx, appcelerator sdk 5.3.0 and testing on google nexus Android 6.0. Ti.Media.showCamera not opening camera even if permissions are granted. Here is my code
function openCamera(parms) {
if (Ti.Media.hasCameraPermissions) {
Ti.API.error("Yes has camera permission");
Ti.Media.showCamera({
success : function(event) {
parms.source.image = newBlob;
},
cancel : function() {
Ti.API.error("User cancelled pictur selection");
},
error : function(error) {
var a = Ti.UI.createAlertDialog({
title : 'Camera Error'
});
if (error.code == Ti.Media.NO_CAMERA) {
a.setMessage("No Camera Found!");
} else {
a.setMessage('Unexpected Error: ' + error.code);
}
a.show();
},
mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO],
animated : true,
autoHide : true,
allowEditing : true,
saveToPhotoGallery : false,
showControls : true
});
} else {
Ti.API.error("No camera permission. Asking for Permission");
Ti.Media.requestCameraPermissions(function(e) {
Ti.API.error(JSON.stringify(e));
if (e.success === true) {
openCamera(parms);
} else {
alert("Access denied, error: " + e.error);
}
});
}
};
In console log this displayed
Yes has camera permission
[WARN] : InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
Would someone point me out what is wrong here.
Hiii I think you are missing brackets after hasCameraPermissions. hasCameraPermissions() is a method defined inside Ti.Media.
Use it like this:
if(hasCameraPermissions()){
//Do you code.....
}