Ti.Media.showCamera 即使授予相机权限也不显示 Android 6.0 Titanium

Ti.Media.showCamera not showing even if camera permissions are granted Android 6.0 Titanium

我的开发环境是 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);
            }
        });
    }
};

在控制台日志中显示

Yes has camera permission

[WARN] : InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.

谁能指出我这里有什么问题。

嗨,我认为您在 hasCameraPermissions 后缺少括号。 hasCameraPermissions() 是 Ti.Media 中定义的方法。 像这样使用它: if(hasCameraPermissions()){ //Do you code..... }