Android Question Sending message to waiting queue of uninitialized activity (submitjob)

hatzisn

Expert
Licensed User
Longtime User
I do not know if this is generally valid but I've found a solution for this error. If you call a wait for a job in a sub (Number2Sub) which is resumable sub and is called with a wait for then the ball is lost completely. So the answer is do not call wait for in a wait for.

B4X:
Sub Number1Sub
    Wait For (Number2Sub) Complete (Result As boolean)
End Sub

Sub Number2Sub As ResumableSub
    dim hj as HttpJob
    hj.initialize("code1", Me)
    hj.download("http://www.somesite.org")
    
    wait for (hj) JobDone(job As HttpJob)
    If job.success then
        'Never fires
    End If
    Return True
End Sub
 

agraham

Expert
Licensed User
Longtime User
I do not know if this is generally valid
It is certainly not generally valid. You are not correctly calling your HttpJob as a Resumable Sub.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
It is certainly not generally valid. You are not correctly calling your HttpJob as a Resumable Sub.

Hi @agraham. I am not sure I understood what you answered me. Can you please copy my code above and show me what I am doing wrong. I checked the link you posted and I did not find anything relative (with a brief look at least).
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I've never used HttpJob but all the examples I've seen would have your Wait For line as
B4X:
wait for (hj) JobDone(hj As HttpJob)
but I have to admit that I don't know why. There are still odd corners of Resumable Subs that I don't fully understand.
 
Last edited:
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
I see... I have used it this way a lot of times and it works perfect. Maybe there is not specific need for this and is more of a syntax thing.
When I remove though in Number1Sub the wait for it actually works with no problem.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Moved to the questions forum.

Your conclusion is wrong. Based on the message in the title it is related to a paused activity. There isn't enough information here to say what exactly happens. Try to reproduce it in small project.

Best solution, as usual, is to switch to B4XPages and forget from all such issues.

You are by 95% right. In my Samsung SM-J730F I cannot reproduce it. The error appeared in a client's phone (Xiaomi Mi) and it was solved by removing the Wait For in the loop. The other 5% is that in the client's phone no Activity is destroyed when the code (button1_Click) is called (it has been destroyed and recreated before). I doubt thus a little if this is the cause of this error. I attach a small project and if someone has a Xiaomi Mi and wants to try to reproduce it, any results are highly welcomed.
 

Attachments

  • ReproduceError_WaitFor_In_WaitFor.zip
    9.7 KB · Views: 230
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
Seems to work fine in release mode on my Xiomi Mi Max 3 with Android 10 and MIUI Global 12.0.1 and also on my Redmi Note 9 Pro with Android 10 and MIUI Global 11.0..6.

It's also fine on a Galaxy A3 with Android 8, a Pixel 4a with Android 11 and a Galaxy Tab A 8 with android 10.
 
Last edited:
Upvote 0
Top