'Can not open two camera ( front and back) at same time

My project in git I wanna open 2 camera (front and back) and display preview in screen. If I open single camera then it's Ok. But I have trouble when open 2 camera same time, one in two camera error follow when I change code in activity_main.xml

  • Here, Back facing cam error:

    <androidx.fragment.app.FragmentContainerView
      android:id="@+id/fragmentContainerView3"
      android:name="com.example.camera13.FrontCamera"
      android:layout_width="400dp"
      android:layout_height="360dp"
      android:layout_marginStart="5dp"
      android:layout_marginEnd="6dp"
      android:layout_marginBottom="8dp"
      android:background="@color/black"
      app:layout_constraintBottom_toTopOf="@+id/fragmentContainerView4"
      app:layout_constraintDimensionRatio="4:3"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHorizontal_bias="0.0"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" />
    
      <androidx.fragment.app.FragmentContainerView
          android:id="@+id/fragmentContainerView4"
          android:name="com.example.camera13.BackCamera"
          android:layout_width="400dp"
          android:layout_height="360dp"
          android:layout_marginStart="5dp"
          android:layout_marginTop="8dp"
          android:layout_marginEnd="6dp"
          android:layout_marginBottom="3dp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintDimensionRatio="4:3"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.0"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/fragmentContainerView3" />
    
  • If i move position fragmentContainerView3 for fragmentContainerView4 then now Front facing cam error.

  • It my detected but seem funny, sr cause I am newbie.

  • I read some posts, they said cause hardware but the post since 9 year ago. My device qualcomm snapdragon 210/212, cores 4, Android 7.2

Tk for help

( I wana recording same time but i think later, but I appreciate any help for this :D)

Update1: Reason is my hardware.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source