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
Remember that that a call to Sleep or Wait For in a resumable sub causes the code flow to return to the parent. Example: Sub Button1_Click Sum(1, 2) Log("after sum") End Sub Sub Sum(a As Int, b As Int) Sleep(100) 'this will cause the code flow to return to the parent Log(a + b) End Sub...
Remember that that a call to Sleep or Wait For in a resumable sub causes the code flow to return to the parent. Example: Sub Button1_Click Sum(1, 2) Log("after sum") End Sub Sub Sum(a As Int, b As Int) Sleep(100) 'this will cause the code flow to return to the parent Log(a + b) End 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).
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.
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.
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.
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.