Android Question [SOLVED] Error trying reusing CameraExClass

makis_best

Well-Known Member
Licensed User
Longtime User
Hi

I use CameraExClass and until one point working fine.

I have a button and when I press it activate the camera.... until now everything work fine.
The camera open and I can use it.

The problem is when I press back softkey end return to previous Layout and then I try to
push the button witch activate the camera again then I get one error message end my program crash.

findCamera
1
2
facing: 0, 0
0
Error occurred on line: 113 (CameraExClass)
java.io.IOException: setPreviewTexture failed
at android.hardware.Camera.setPreviewSurface(Native Method)
at android.hardware.Camera.setPreviewDisplay(Camera.java:748)
at anywheresoftware.b4a.objects.CameraW.StartPreview(CameraW.java:176)
at gr.iosif.cameraexclass._startpreview(cameraexclass.java:397)
at gr.iosif.egm_camera._camera1_ready(egm_camera.java:898)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1083)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1038)
at gr.iosif.cameraexclass._camera_ready(cameraexclass.java:662)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.CameraW$2$1.run(CameraW.java:139)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5376)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
 

makis_best

Well-Known Member
Licensed User
Longtime User
CameraEx example doesn't have home screen, and runs fine every time I use it.
When I press back app exit.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
and wehen you then restart it? Does it work?
 
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
Sure I can...

B4X:
Sub Activity_Resume
    InitializeCamera
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    If camEx.IsInitialized Then
        camEx.Release
    End If
End Sub
 
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
I find the problem... one of the five different options I use to exit from layout I didn't release the CameraExClass.
Now it is working fine.
 
Upvote 0
Top