Android Question in CamEx2: surfaceTexture must not be null

Cadenzo

Active Member
Licensed User
Longtime User
Using this Exemple I get sometimes the error
'java.lang.IllegalArgumentException: surfaceTexture must not be null
B4X:
Public Sub PrepareSurfaceForVideo (MyTaskIndex As Int, Dir As String, FileName As String) As ResumableSub
    If MyTaskIndex <> TaskIndex Then Return False
    CloseSession
    Wait For (CreateSurface) Complete (Result As Boolean)
    If MyTaskIndex <> TaskIndex Then Return False
    File.Delete(Dir, FileName)
    MediaRecorder = Camera.CreateMediaRecorder(PreviewSize, Dir, FileName)
    MediaRecorder.RunMethod("setOrientationHint", Array(GetHintOrientation))
    Camera.StartSession(tv, PreviewSize, CaptureSize, 0, 0, True) 'ToDo: java.lang.IllegalArgumentException: surfaceTexture must not be null
    Wait For Camera_SessionConfigured (Success As Boolean)
    If MyTaskIndex <> TaskIndex Then Return False
    Return Success
End Sub
I use the original example (V1.30), only I removed the code to another activity and call this activity in Main with Button "Start Record".
It seems to be something with a destroyed view, because this error happens only sometimes, when starting the Record Activity, but I could not fix it yet.
 

JohnC

Expert
Licensed User
Longtime User
I don't know if this will help, but I was getting a few intermitted crashes with the camera and I had to do this:
B4X:
Sub Activity_Resume
        Sleep (500)    'delay needed to avoid crashing
        InitializeCamera   
End Sub
 
Upvote 0
Top