Android Question Camera Ex error

Avansys

Member
Licensed User
Longtime User
Sometimes when I try to use the camera, while activity starts, I get a black screen for a while and then appears the follow errors: camera_focusdone: AutoFocus error, camera_ready: java.lang.RuntimeException: Fail to connect to camera service.
Here is an example of the errors:

B4X:
cameraexclass_startpreview (java line: 601)
java.lang.RuntimeException: startPreview failed
    at android.hardware.Camera.startPreview(Native Method)
    at anywheresoftware.b4a.objects.CameraW.StartPreview(CameraW.java:177)
    at efa.avansys.ultracable.ventas.cameraexclass._startpreview(cameraexclass.java:601)
    at efa.avansys.ultracable.ventas.tomarfoto._cameraevent_ready(tomarfoto.java:405)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:834)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:792)
    at efa.avansys.ultracable.ventas.cameraexclass._camera_ready(cameraexclass.java:128)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    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:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3824)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: startPreview failed
** Activity (tomarfoto) Pause, UserClosed = true **
** Activity (documentos) Resume **
sending message to waiting queue (smtp_messagesent)
** Activity (documentos) Pause, UserClosed = true **
** Activity (ventanaregistrarservicios) Resume **
** Activity (ventanaregistrarservicios) Pause, UserClosed = false **
** Activity (tomarfirma) Create, isFirst = true **
** Activity (tomarfirma) Resume **
** Activity (tomarfirma) Pause, UserClosed = true **
** Activity (ventanaregistrarservicios) Resume **
** Activity (ventanaregistrarservicios) Pause, UserClosed = false **
** Activity (documentos) Create, isFirst = false **
** Activity (documentos) Resume **
** Activity (documentos) Pause, UserClosed = false **
** Activity (tomarfoto) Create, isFirst = false **
cameraexclass_release (java line: 457)
java.lang.NullPointerException
    at efa.avansys.ultracable.ventas.cameraexclass._release(cameraexclass.java:457)
    at efa.avansys.ultracable.ventas.tomarfoto._btnok_click(tomarfoto.java:337)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:63)
    at android.view.View.performClick(View.java:2485)
    at android.view.View$PerformClick.run(View.java:9080)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3824)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
 

Avansys

Member
Licensed User
Longtime User
Not exactly with CameraEx example, but I based in it to implement my code.
 
Upvote 0

Avansys

Member
Licensed User
Longtime User
I tried the cameraex example and if I give a few clicks at the same time to take the photo, the application crashes and the camera stops working (in any application).

I know this is not a correct use, but What can I do to prevent camera crashes?

B4X:
LogCat connected to: B4A-Bridge: ZTE ZTE V9A-861932010801910
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
running waiting messages (2)
** Activity (main) Resume **
** Service (service1) Destroy **
** Service (service1) Create **
** Service (service1) Start **
Connected to B4A-Bridge (Wifi)
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (camara) Create, isFirst = true **
** Activity (camara) Resume **
java.lang.reflect.InvocationTargetException
success = false, (RuntimeException) java.lang.RuntimeException: Fail to connect to camera service
** Activity (camara) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (camara) Create, isFirst = false **
** Activity (camara) Resume **
java.lang.reflect.InvocationTargetException
success = false, (RuntimeException) java.lang.RuntimeException: Fail to connect to camera service
 
Upvote 0

Avansys

Member
Licensed User
Longtime User
Yeah, I already had implemented it, but what I wanted was to avoid the problem not the cause of the problem.

Finally I decided to use the EZCamera library.

Thanks
 
Upvote 0
Top