After adding the view Panel1 to the activity via code and not layout the camera produces this error during initialization:
The relevant code follows:
B4X:
java.lang.ClassCastException: anywheresoftware.b4a.BALayout cannot be cast to android.view.SurfaceView
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime=True Then CreateEmptyShortCut
Activity.LoadLayout("1")
pn1.Initialize("pn1")
pn2.Initialize("pn2")
pn3.Initialize("pn3")
pn4.Initialize("pn4")
pn5.Initialize("pn5")
panel1.Initialize("panel1")
PANEL2.Initialize("panel2")
panel1.Color=Colors.DarkGray
PANEL2.Color=Colors.Red
Activity.AddView(panel1,50,0,910,640)
panel1.AddView(PANEL2,190,80,630,10)
End Sub
B4X:
Private Sub InitializeCamera
camEx.Initialize(panel1, backCamera, Me, "Camera1")
backCamera = camEx.Front
End Sub
B4X:
Sub Activity_Resume
InitializeCamera
end sub