Sub Globals
Dim Panel1 As Panel
Dim Panel2 As Panel
Dim frontCam As Camera
Dim backCam As Camera
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("lg")
Dim numberOfCameras As Int = r.RunStaticMethod("android.hardware.Camera", "getNumberOfCameras", Null, Null)
ToastMessageShow("# of cameras" & numberOfCameras,True)
End Sub
Private Sub InitializeCameras
frontCam.Initialize2(Panel1,"frontCamera",1)'' the first camera initialized produces an error when starting its preview
backCam.Initialize2(Panel2,"backCamera",0) '' the second camera initialized runs fine.
End Sub
Sub backCamera_Ready (Success As Boolean)
If Success Then
backCam.StartPreview
Else
Msgbox("cannot open back camera","")
End If
End Sub
Sub frontCamera_Ready (Success As Boolean)
If Success Then
frontCam.StartPreview'' This raises an error "java.lang.RunTimeException: Method called after release()"
Else
Msgbox("cannot open front camera","")
End If
End Sub
Sub Activity_Resume
InitializeCameras
End Sub
Sub Activity_Pause (UserClosed As Boolean)
frontCam.StopPreview
backCam.StopPreview
frontCam.Release
backCam.Release
End Sub