Android Question HttpJob crash

Teech

Member
Licensed User
Longtime User
Goodmorning.
I looking for help about a process that doesn't return any result and any error, just crash
My code is:
Code:
Public Sub GetCustomers(target As Object)
    If Not(m_customers.IsInitialized) Then
        m_customers.Initialize
        Wait For (LoadCustomers(target, "")) Complete (unfinished As String)
        If  unfinished<>"" Then
            LoadCustomers(target, unfinished)
        Else
            Log("DOWNLOADED!!!!!")
        End If
    End If
End Sub
Private Sub LoadCustomers(target As Object, nxt As String) As ResumableSub
    Dim unfinished As String=""
    Dim J As HttpJob
    J.Initialize("customers",target)

    Dim uri As String
    uri=$"https://myurl/customers"$
    If nxt<>"" Then uri=$"${uri}&next=${nxt}"$
    Log(uri)
    j.Download(uri)
    setHeader(j)
  
    Wait For (j) JobDone (j As HttpJob)
    If j.Success Then
        Dim parser As JSONParser
        parser.Initialize(j.GetString)
        Dim root As Map = parser.NextObject
        Dim db As DatabaseManager
        db.Initialize
        db.AddCustomers(root.Get("dati"))
        If root.ContainsKey("next") Then unfinished=root.Get("next")
        Log(unfinished)
    Else
        Log(j.ErrorMessage)
    End If
    j.Release
    Return unfinished
End Sub
In SetHeader(j) i add some header request by the EndPoint thet i have already verify: I have also added 20 seconds timeout.
Using an API Client (Insomnia) I have a response from webservice.


The problem is in Sub LoadCustomers after "Wait For (j) JobeDone": the process first same locke and then crash so line "If j.Success Then" never run. In Log I can see
*** Service (httputils2service) Create ***

After about 30 second I receive a "*MyApp* isn't responding" message on device with 2 option, Close o Wait (my choice is Close for sure).
On B4A Log there is this error message:
** Activity (main) Pause, UserClosed = false **
java.lang.RuntimeException: Unable to create service com.mbconsulenze.httputils2service: java.lang.RuntimeException: anywheresoftware.b4a.B4AUncaughtException
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4381)
at android.app.ActivityThread.access$1700(ActivityThread.java:273)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2112)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Caused by: java.lang.RuntimeException: anywheresoftware.b4a.B4AUncaughtException
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:188)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at com.mbconsulenze.httputils2service.onCreate(httputils2service.java:56)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4369)
... 8 more
Caused by: anywheresoftware.b4a.B4AUncaughtException
at anywheresoftware.b4a.Msgbox.debugWait(Msgbox.java:210)
at anywheresoftware.b4a.debug.Debug.wait(Debug.java:217)
at anywheresoftware.b4a.shell.Shell.debugPause(Shell.java:544)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:417)
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)
... 11 more
I have installed B4A v.12.20.
Have any suggest? Thanks
 

DonManfred

Expert
Licensed User
Longtime User
Upload a small project showing the problem.
 
Upvote 0
Top