HttpUtils2 doesn't call JobDone in Classes

airblaster

Active Member
Licensed User
Longtime User
I have a class module that uses HttpUtils2.
In this class I call HttpJob like this:
B4X:
Dim job1 As HttpJob
job1.Initialize("Jobname", Me)
The Job downloads successfully, but the JobDone method in the class is never called.

Why does this happen? How to fix it?
 

airblaster

Active Member
Licensed User
Longtime User
Just wrote a small sample app, but it worked just fine. So its not a general problem of HttpJob.
I'll do some more research on what could be causing the problem.
 
Upvote 0

airblaster

Active Member
Licensed User
Longtime User
Just noticed that the Log contains some information that might be useful:
HTML:
Object context is paused. Ignoring CallSubDelayed: JobDone
What exactly does this mean?
That the calling Activity was paused? That the class module containing the HttpJob was paused? Or that the Code module containing the class that uses HttpJob was paused?
 
Upvote 0

airblaster

Active Member
Licensed User
Longtime User
Probably it meant that the code module containing the instance of the class that is using HTTPJob was paused:
I moved the object to the activity module using it and everything works.

The strange thing is: I used exactly the same setup in the sample app and it worked there.
Could this be a bug in B4A?

As a workaround I'll be instanciating the class in every activity using it, even though a single instance would be enough otherwise.
 
Upvote 0

zsezo

Member
Licensed User
Longtime User
I'm a little bit confused...
I have to use a web service which is working with post methods, but I don't know what is the standard way to use. I'm a newcomer for android and for a4b as well.

I have 4 url. Like
- 'http://192.168.1.100/getpackagestatus' json formatted post param and result is only a string
- 'http://192.168.1.100/setpackagestatus' json formatted post param and result is only a string
- 'http://192.168.1.100/getMotorParameters' json formatted post param and result is jsonformatted
- 'http://192.168.1.100/setMotorParameters' json formatted post param and result is jsonformatted

I don't know how can I start. Yes, I'm a little bit confused, because every modul has only one JobDone for four function?
In this situation, should I have to create 4 standalone codemodule or... what?
TIA
 
Upvote 0

lagore

Active Member
Licensed User
Longtime User
Set up your 'posts' with the URL and post data as follows (2 shown)
B4X:
Dim job1, job2 As HttpJob
    Dim postUrl_1, PostUrl_2 As String
    Dim postData_1, postData_2 As String
    postUrl_1 = "http://192.168.1.100/getpackagestatus"
    PostUrl_2 = "http://192.168.1.100/setpackagestatus"
    postData_1 = "what ever data 1 is"
    postData_2 = "what ever data 2 is"
   
    job1.Initialize("POST Job1", Me)
    job1.PostString(postUrl_1, postData_1)
   
    job2.Initialize("POST Job2", Me)
    job2.PostString(PostUrl_2, postData_2)
then you will have one job done and test for the job name.
B4X:
Sub JobDone (job As HttpJob)
   
    If job.Success = True Then
        Select job.JobName
            Case "POST Job1"
                'do some processing
            Case "POST Job2"
                'do some processing
        End Select
   
    End If
    job.Release
End Sub

ps Erel would probably prefer you to start a new thread
 
Upvote 0

zsezo

Member
Licensed User
Longtime User
Thank lagore, works like a charm! Should I brave and continue?
I have an Activity with a listbox. What is the easyest way to update all of my item?
Initially the items looks like "Mtr9128181 - unknow state" and I have to send a query to the server to get states and I have to update all item from 'unknow' state to present...

From

"Mtr9128181 - unknow state"
"Mtr9128182 - unknow state"
"Mtr9128183 - unknow state"
"Mtr9128184 - unknow state"

To

"Mtr9128181 - Spinning up"
"Mtr9128182 - Ok@18000"
"Mtr9128183 - malfunction"
"Mtr9128184 - Ok@18000"


As I see, with this method I got the answers in "faster is sooner" order. What is your suggestions?
 
Last edited:
Upvote 0

lagore

Active Member
Licensed User
Longtime User
You are correct, the return order is not necessarily the same as the send order, how you handle this depends on what you are doing. I have a login process with 7 posts each one triggers the next one.
 
Upvote 0

Claudio Oliveira

Active Member
Licensed User
Longtime User
Classes share the context of the activity that initialized them. I assume from the logs that the class initializing activity is paused when JobDone is called.
So, that means my "JobDone" sub should be located on my activity module?
I'm having the same problem. I've built a class module where I query (GET) a web site and build a structure (map) containing the results of my query. But the "JobDone" sub is never called whatsoever.
If I use a service instead, everything works fine.
Maybe I'm missing something here...:confused:
 
Upvote 0
Top