Android Question cctv CAMERA

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
hello all
i have downloaded the cctv b4a client and b4j server they connected and run fine,
when i open the android app it gives the following error
Logger connected to: Xiaomi Redmi 6 Pro
--------- beginning of system
--------- beginning of crash
--------- beginning of main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (communicator) Create ***
Connecting to: 10.0.0.203:17178
** Service (communicator) Start **
Client_Connected: true
90, 90
Supported sizes:
4000x3000
4000x2250
4000x2250
4000x2000
3840x2160
3264x2448
3200x2400
2976x2976
2592x1944
2688x1512
2592x1458
2592x1296
2048x1536
1920x1080
1920x960
1600x1200
1440x1080
1280x960
1280x768
1280x720
1280x640
1200x1200
1024x768
800x600
864x480
800x480
720x480
640x480
640x360
480x640
480x360
480x320
352x288
320x240
java.lang.Exception: Sub astreams_newdata was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:202)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Unknown Source:2)
at android.os.Handler.dispatchMessage(Unknown Source:4)
at android.os.Looper.loop(Unknown Source:155)
at android.app.ActivityThread.main(Unknown Source:65)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
at com.android.internal.os.ZygoteInit.main(Unknown Source:345)
java.lang.RuntimeException: java.lang.Exception: Sub astreams_newdata was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:233)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Unknown Source:2)
at android.os.Handler.dispatchMessage(Unknown Source:4)
at android.os.Looper.loop(Unknown Source:155)
at android.app.ActivityThread.main(Unknown Source:65)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
at com.android.internal.os.ZygoteInit.main(Unknown Source:345)
Caused by: java.lang.Exception: Sub astreams_newdata was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:202)
... 8 more
the downloaded example code b4a client as following
ok:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: False
    #ApplicationLabel: Camera example
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region
#Region  Activity Attributes
    #FullScreen: True
'    #IncludeTitle: True
      #BridgeLogger: True
#End Region
'Activity module
Sub Process_Globals
    Private frontCamera As Boolean = False
    Public ServerIp As String = "10.0.0.203"
    Public ServerPort As Int = 17178
    Private IntervalMs As Int = 150
    Private lastPreviewSaved As Long
End Sub

Sub Globals
    Private Panel1 As Panel
    Private camEx As CameraExClass
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    StartService(Communicator)
End Sub

Sub Activity_Resume
    InitializeCamera
End Sub

Private Sub InitializeCamera
    camEx.Initialize(Panel1, frontCamera, Me, "Camera1")
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    camEx.Release
End Sub

Sub Camera1_Ready (Success As Boolean)
    If Success Then
        camEx.StartPreview
        Log("Supported sizes:")
        For Each size As CameraSize In camEx.GetSupportedPicturesSizes
            Log(size.Width & "x" & size.Height)
        Next
        camEx.SetJpegQuality(40)
        Log(camEx.GetSupportedFlashModes)
        camEx.CommitParameters
    Else
        ToastMessageShow("Cannot open camera.", True)
    End If
End Sub

Sub btnTakePicture_Click
    camEx.TakePicture
End Sub

Sub Camera1_Preview (PreviewPic() As Byte)
    If DateTime.Now > lastPreviewSaved + IntervalMs Then
        Dim jpeg() As Byte = camEx.PreviewImageToJpeg(PreviewPic, 70)
        lastPreviewSaved = DateTime.Now
        CallSubDelayed2(Communicator, "Send", jpeg)
    End If
End Sub

Sub Camera1_PictureTaken (Data() As Byte)
    camEx.SavePictureToFile(Data, File.DirRootExternal, "1.jpg")
    camEx.StartPreview
End Sub

Sub btnEffect_Click
    Dim effects() As String = Array As String("aqua", "blackboard", "mono", "negative", "posterize", _
        "sepia", "solarize", "whiteboard")
    Dim effect As String = effects(Rnd(0, effects.Length))
    camEx.SetColorEffect(effect)
    ToastMessageShow(effect, False)
    camEx.CommitParameters
End Sub

Sub ChangeCamera_Click
    camEx.Release
    frontCamera = Not(frontCamera)
    InitializeCamera
End Sub
and the b4j server code id
main:
'Non-UI application (console application)
#Region  Project Attributes
    #CommandLineArgs:
    #MergeLibraries: False
#End Region

Sub Process_Globals
    Private srvr As Server
    Public images As Map
End Sub

Sub AppStart (Args() As String)
    srvr.Initialize("")
    srvr.Port = 17178

    srvr.AddHandler("/SendImage", "SendImage", False)
    srvr.AddHandler("/GetImages", "GetImages", False)
    srvr.AddHandler("/GetImage", "GetImage", False)
    srvr.Start
    images = srvr.CreateThreadSafeMap
    StartMessageLoop
End Sub
<<<<<<
server b4j error is
i'd like to note that my camera lib version is 2.20,
i searched a lot but i did not find the error of( Sub astreams_newdata was not found.) in the forum,
i hope to solve that ,
thank you in advance.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…