Android Question How to close/hide CameraEX routine

jalvarez

Member
Licensed User
Longtime User
Hi everybody!

In my project I need to take an undetermined number of photos, I'm using CameraEX class and works fine BUT I have the next error:

** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
~w:1004,main,231
~w:1004,main,307
~w:1004,main,396
findCamera
null
2
facing: 0, 0
findCamera
0
2
facing: 0, 0
90
~w:1004,main,396
findCamera
null
2
facing: 0, 0
findCamera
0
2
facing: 0, 0
90
cameraexclass_startpreview (B4A line: 114)
cam.StartPreview
java.io.IOException: setPreviewTexture failed
at android.hardware.Camera.setPreviewDisplay(Native Method)
at android.hardware.Camera.setPreviewDisplay(Camera.java:499)
at anywheresoftware.b4a.objects.CameraW.StartPreview(CameraW.java:176)
at de.amberhome.slidemenuexample.cameraexclass._startpreview(cameraexclass.java:1526)
at de.amberhome.slidemenuexample.main._camera1_ready(main.java:983)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:897)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:839)
at de.amberhome.slidemenuexample.cameraexclass._camera_ready(cameraexclass.java:146)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.CameraW$2$1.run(CameraW.java:139)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException: setPreviewTexture failed

This happens when I use next piece of code, that also works:

Sub RemoveViews
Dim i As Int
For i = Activity.NumberOfViews - 1 To 108 Step -1
Activity.RemoveViewAt(i)
Next
End Sub

I invoke the camera routine from an Imageview control inside a CustomListView, so the user can choose which one could have a photo, that why I must close and open the camera several times. Please help to understand how to close this class wihout errors.
I've uploaded the source code as well.
Thanks to all.
jalvarez
 

Attachments

  • project.zip
    8.4 KB · Views: 234

jalvarez

Member
Licensed User
Longtime User
Neve mind, I fixed this problem, I changed the code in btnSalida button that exits this sub and the error disappeared. Thanks anyway

Sub btnSalida_Click
RemoveViews
camEx.Release
End Sub
 
Upvote 0
Top