【发布时间】:2025-12-31 05:50:09
【问题描述】:
我的开发环境是mac osx,appcelerator sdk 5.3.0,在google nexus Android 6.0上测试。即使授予权限,Ti.Media.showCamera 也不会打开相机。这是我的代码
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);
}
});
}
};
在控制台日志中显示
是的,有摄像头权限
[WARN] : InputEventReceiver: 试图完成一个输入事件但是 输入事件接收器已被释放。
有人能指出这里有什么问题吗?
【问题讨论】:
标签: titanium appcelerator titanium-mobile appcelerator-titanium android-6.0.1-marshmallow