Android Question HttpJob Intermittent Crashes

DawningTruth

Active Member
Licensed User
The following code works, but intermittently crashes. It is pretty much exactly what is described in the examples. So I am stumped.

Code: Copy
Sub UrlFetch(getUrl As String, param() As String) As ResumableSub
    
    Log("==============================================")
    Log(">> UrlFetch")
    Log("==============================================")
    
    Dim job As HttpJob
    Dim urlContent As String
    
    job.Initialize("", Me)

    job.Download2(getUrl,param)
    Log("FINISHED: UrlFetch -> Start Download Job") 'Checking if request is executed
    Wait For (job) JobDone (job As HttpJob)
    Log("FINISHED: UrlFetch -> End Download Job") 'Checking if response is executed
    
    If job.Success Then
        Log(job.GetString)
        urlContent = job.GetString
    Else
        Log("Error: " & job.ErrorMessage)
    End If
    job.Release
    
    'CallSubDelayed(Me, "UrlFetch_Complete")
    
    Log("FINISHED: UrlFetch") 'Check if sub finished
    Return urlContent
    
End Sub

Here are the Logs:
uBMk0q.jpg


Any assistance is greatly appreciated.
 
1. Please post the full error message as text.
2. And also tell us where exactly it fails.
Thx Erel, as requested:

1. Full Error Message as Text (in red)

==============================================
>> UrlFetch
==============================================
FINISHED: UrlFetch -> Start Download Job
==============================================
>> UrlFetch
==============================================
FINISHED: UrlFetch -> Start Download Job
Error occurred on line: 2036 (MyActivity)
java.lang.ClassCastException: java.lang.Object cannot be cast to b4a.example.main$_event_item_flag
at b4a.example.MyActivity$ResumableSub_MyWebview_PageFinished.resume(MyActivity.java:5025)
at b4a.example.MyActivity._MyWebview_pagefinished(MyActivity.java:4994)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.WebViewWrapper$1.onPageFinished(WebViewWrapper.java:60)
at uU.d(PG:307)
at aIV.handleMessage(PG:73)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7045)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

2. Where it fails...


Based on the logs above I presume it fails at the:

Wait For (job) JobDone (job As HttpJob)

As per the comment below:

Code: Copy
job.Download2(getUrl,param)
Log("FINISHED: UrlFetch -> Start Download Job") 'Checking if request is executed[/COLOR][/COLOR]
Wait For (job) JobDone (job As HttpJob) '<==== FAILS HERE - Does not go to the next step
Log("FINISHED: UrlFetch -> End Download Job") 'Checking if response is executed
 
Upvote 0
Back
Top