Android Question CameraExClass cannot show preview in tablet

hung

Active Member
Licensed User
Longtime User
I have an app running for years on Lenovo TAB M10 and M8 without problem in past years.

But recently the camera does not show preview and any camera actions will crash the app in both tablets. I use the cameraex library for taking photo and scanning barcode. Taking photo ok but scanning barcode cannot even show camera preview.

However, same app is still running ok on my old and new mobile phones.

B4X:
    gRp.CheckAndRequest(gRp.PERMISSION_CAMERA)
    Wait For Activity_PermissionResult  (Permission As String, Result As Boolean)
    If Result = False Then
        Log("Camera no permission")
        Return
    End If

    pnl_preview.Visible = True
    camex.Initialize(pnl_preview, False, Me, "CamBarcode")
    Wait For CamBarcode_Ready (Success As Boolean)
    If Success Then
...

When debug in tablet, I noticed "Wait For CamBarcode_Ready" has never come back. Both manifest and RunningPermission have allow camera permission. When further debug, the program stopped at
B4X:
cam.Initialize2(Panel1, "camera", id)

inside CameraExClass libray.

Two camera are found and back camera is selected. But just cannot initialize on Tablet. Any hints to this problem?
 
Last edited:

hung

Active Member
Licensed User
Longtime User
Where is the error message?
I found camera preview ok and could take photo now. But barcode scanning event has issue.

No preview. When try to zoom, crash as below

B4X:
findCamera
null
2
facing: 0, 1
facing: 1, 1
findCamera
0
2
facing: 0, 1
facing: 1, 1
Continuous focus mode is not available
findCamera
null
2
facing: 0, 0
Error occurred on line: 350 (CameraExClass)
java.lang.NoSuchMethodException: java.lang.Object.setZoom [int]
    at java.lang.Class.getMethod(Class.java:2937)
    at java.lang.Class.getDeclaredMethod(Class.java:2914)
    at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:214)
    at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod2(Reflection.java:817)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA$1.run(BA.java:360)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7941)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:553)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
 
Upvote 0

hung

Active Member
Licensed User
Longtime User
Um. Seems root cause found. Again this issue happened on not long ago and I have been using the camera barcode scanning for long without issue.

I compared my codes for camera photo taking and camera barcode scanning. Both have two variants (320x480 and 800x400). Camera works but Camera Barcode Scanning not working.

I found the layout for camera photo taking has not resized or moved the preview panel as I just need autoscale to 100%x and 100%y. But the Camera Barcode Scanning has resized and moved as it does not use full screen.

Once I delete the 800x400 variant for Camera Barcode Scanning and just keep 320x480, it works on tablet. i.e. no pnl_preview resizing nor moving in Variant Script.

Not sure why and not understand why but now works. Case close temporally.
 
Upvote 0
Top