Skip to content

Not currently allowed to connect to camera “1”

ANDROID Caused by java.lang.SecurityException: validateClientPermissionsLocked:1102: Callers from device user 0 are not currently allowed to connect to camera “1”

Camera permission is granted.

It is runned by a FOREGROUND SERVICE.

Works on most devices, but there are few Android 9, Huawei, Motorola and Xiaomi devices that is not working on.

On this link:

Line 1031 explains: “Only allow clients who are being used by the current foreground device user.”

Does this mean that it cannot be accessed by a foreground service?

Code in Kotlin (crash occurs at manager.openCamera):

 try {
            val pickedCamera = getCamera(manager) ?: return
            if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
                != PackageManager.PERMISSION_GRANTED
            ) {
            manager.openCamera(pickedCamera, cameraStateCallback, null)
            imageReader =
                ImageReader.newInstance(1920, 1088, ImageFormat.JPEG, 1 /* images buffered */)
            imageReader.setOnImageAvailableListener(onImageAvailableListener, null)
        } catch (e: CameraAccessException) {



After analyzing more the crash, I saw that 100% of the users with this crash, had their proximity sensor activated (provided by Firebase Crashlytics).

I wrote some code to avoid using the camera when the proximity sensor was on and it fully solved the problem.

I do not know what was the logic behind it, but it worked 🙂

User contributions licensed under: CC BY-SA
1 People found this is helpful