Edit: See 3rd Post.
I am seeing something similar to this.
I get the error in both B4A and B4J'
It Occurs in the following code:
I am not sure if it has anything to do with GetPicFromServer because here is the interesting part:
Let me see if I can list the various conditions. These all apply to the GetPic sub.
B4J Debug mode:
Adding a Break anywhere in the sub prevents the problem. THE CODE DOES NOT HAVE TO ACTUALLY HIT THE BREAK AND STOP.
Remming the line
IF I rem the Try Catch block AND put a break line the code runs and
I have similar results in Android.
I cannot get it working in Release Mode.
I am seeing something similar to this.
I get the error in both B4A and B4J'
B4X:
B4J
https://www.b4x.com/android/forum/threads/class-java-lang-error-cannot-be-cast-to-class-java-lang-exception.118465/
B4A
(ClassCastException) java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String[]
It Occurs in the following code:
B4X:
Sub GetPic
Try
' Dim req As DBRequestManager = req.Initialize(Me, $"http://${IPAddre.Text}:17178/rdcx"$)
' Dim cmd As DBCommand = CreateCommand("GetEmployees", Array())
Dim FN As String = ""
Dim FDir As String = ""
Dim H As HttpJob
H.Initialize("H", Me)
'Sleep(10)
Dim XXX As Int
#IF B4A
Dim B As Bitmap
B.InitializeMutable(TravPic.mBase.Width, TravPic.mBase.Height)
TravPic.Bitmap = B
#ELSE
' Dim C As Canvas
' C.Initialize("")
' Dim FX As JFX
' C.ClearRect(0, 0, 1000, 1000)
' C.DrawLine(0, 0, 8, 8, FX.Colors.Black , 5)
' TravPic.Bitmap = C.Snapshot
#END IF
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("PMPicTest", Array())
TextArea1.Text = "Getting 5 pictures"
Sleep(100)
Wait For (req.ExecuteQuery(cmd, 0, "")) JobDone(j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(res As DBResult)
For Each row() As String In res.Rows
TextArea1.Text = $"${TextArea1.Text}
${row(0)}
"$
#IF B4J
FN = File.GetName(row(0))
FDir = File.GetFileParent(row(0))
If File.Exists(FDir, FN) Then
XXX = XXX+ 1
Wait For(GetPicFromServer(FN, FDir)) Complete(R As Boolean)
TextArea1.Text = TextArea1.Text & CRLF & "Wait 1 Second"
Sleep(1000)
If XXX > 5 Then Exit
End If
#ELSE
Dim FDir As String = row(0).SubString2(0, row(0).LastIndexOf("\"))
Dim FN As String = row(0).SubString(row(0).LastIndexOf("\") + 1)
XXX = XXX+ 1
Wait For(GetPicFromServer(FN, FDir)) Complete(R As Boolean)
TextArea1.Text = TextArea1.Text & CRLF & "Wait 1 Second"
Sleep(1000)
If XXX > 5 Then Exit
#END IF
Next
Else
Log("ERROR: " & j.ErrorMessage)
TextArea1.Text = TextArea1.Text & CRLF & j.ErrorMessage
End If
j.Release
Catch
Log(LastException)
End Try
End Sub
Sub GetPicFromServer(FN As String, FDir As String) As ResumableSub
Dim H As HttpJob
H.Initialize("H", Me)
Dim T As Long = DateTime.Now
H.Download2($"http://${IPAddre.Text}:17178/getfile"$, Array As String("FileName", FDir & "\" & FN, "Dir", FDir))
Wait For (H) JobDone(j As HttpJob)
If j.Success Then
TextArea1.Text = TextArea1.Text & "Got Picture in " & ((DateTime.Now - T) / 1000) & " Seconds."
If j.GetString2("UTF8").SubString2(0, 6).EqualsIgnoreCase("Failed") Then
TextArea1.Text = $"Couldn't find ${FDir}\${FN}"$
Else
T = DateTime.Now
TravPic.Bitmap = j.GetBitmap
TravPic.ResizeMode = "FIT"
TextArea1.Text = TextArea1.Text & CRLF & "Load Picture in " & ((DateTime.Now - T) / 1000) & " Seconds."
End If
End If
j.Release
Return True
End Sub
I am not sure if it has anything to do with GetPicFromServer because here is the interesting part:
Let me see if I can list the various conditions. These all apply to the GetPic sub.
B4J Debug mode:
Adding a Break anywhere in the sub prevents the problem. THE CODE DOES NOT HAVE TO ACTUALLY HIT THE BREAK AND STOP.
Remming the line
Log(LastException)
inside the catch block prevents the problem.IF I rem the Try Catch block AND put a break line the code runs and
Log(LastException)
Logs (Exception) Not initialized
I have similar results in Android.
I cannot get it working in Release Mode.
Last edited: