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 **
I have installed B4A v.12.20.
Have any suggest? Thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…