How to access concurrent cameras

34 views
Skip to first unread message

Prathiv Ar

unread,
Jan 22, 2026, 11:44:06 PMJan 22
to Android CameraX Discussion Group
I have a use case were I need to stream both cameras(front & back) same time and use ImageAnalysis.Analyzer to make some changes to the frame.

when I bind the first camera everything works fine 

cameraProvider.bindToLifecycle(

    lifecycleOwner,

    cameraSelector,

    preview,

    imageAnalysis

)


But then the second camera try to bind it doesn't work (yes I know) . I get 

Open count: 1 (Max allowed: 1)


But it works fine in camera2 but the camerax as good stability (lifecycle ....). 

I'm bit confused how to go forward . is there any way to achieve this in X ?

Wenhung Teng

unread,
Feb 12, 2026, 2:18:21 AM (5 days ago) Feb 12
to Android CameraX Discussion Group, prath...@gmail.com
Hi there,

To use both cameras simultaneously, you need to use the Concurrent Camera API introduced in CameraX 1.3.0. The error "Open count: 1 (Max allowed: 1)" occurs because CameraX defaults to a single active camera unless you explicitly bind multiple cameras together in a single coordinated call.

Instead of calling bindToLifecycle twice, you must use the call that accepts a list of SingleCameraConfig objects. Please see Concurrent camera sample /   ConcurrentCamera | API 

Here is a quick code snippet based on our integration logic to get you started:

val cameraProvider = ProcessCameraProvider.getInstance(context).await() // 1. Check for available concurrent camera selectors val concurrentCameraInfos = cameraProvider.availableConcurrentCameraInfos if (concurrentCameraInfos.isEmpty()) { // Device does not support concurrent camera return } // 2. Select the first available pair (typically Front + Back) val selectorPair = concurrentCameraInfos[0] val primarySelector = selectorPair[0].cameraSelector val secondarySelector = selectorPair[1].cameraSelector // 3. Define configurations for each camera val primaryConfig = SingleCameraConfig( primarySelector, UseCaseGroup.Builder() .addUseCase(preview0) .addUseCase(imageAnalysis0) // Your Analyzer goes here .build(), lifecycleOwner ) val secondaryConfig = SingleCameraConfig( secondarySelector, UseCaseGroup.Builder() .addUseCase(preview1) .addUseCase(imageAnalysis1) .build(), lifecycleOwner ) // 4. Bind both in a single call val concurrentCamera = cameraProvider.bindToLifecycle(listOf(primaryConfig, secondaryConfig))
Reply all
Reply to author
Forward
0 new messages