Android Question New OkHttpUtils2 (v 3.02) gives "sending message to waiting queue of uninitialized activity (submitjob)" errors

PJLPJLPJL

Member
Licensed User
The problem occurs on
j.download(Url1):
instructions.
After installing this update to OKHttpUtils2 I am now getting log messages saying "sending message to waiting queue of uninitialized activity (submitjob)" and then waiting for ever on the line
wait for (j) JobDone (j as httpjob):


This is true both in a B4xPages activity and in a widget-related service.
Is this something to do with this having become a Receiver?

I've done some more digging, and unzipped the HttpJob and HttpUtils2Service modules from the library and included them in my project. This means I can log traces.
It seems that, first time through, the following line in the HttpJob.Download sub is not working properly
CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me):
Logs suggest that the "uninitialized activity (sumbitjob)" event is happening BEFORE the Service_Create and Broadcast_Receive subs in HttpUtils2Service module have run.

Note that this only seems to be the case first-time through. If the app retries the download it works ok.
Could it be a problem with CallSubDelayed(2) in a Broadcast Receiver situation?

I've got round it very hamfistedly by altering the Broadcast_Receive sub in HttpUtils2Service to retry the SubmitJob request if FirstTime is true but this is horrible and may not work in other contexts.

I'm running latest B4A on Android 9 (Samsung A8)
 

PJLPJLPJL

Member
Licensed User
Thank you Erel. Just to be utterly clear, the correct usage is that OkHttpUtils2 requests can be made in any service in a B4XPages project (but not in any activity including B4XMainPage) but in a non-B4xPages project (eg. a widget) must be made in Starter.

Again, thanks and best wishes.
 
Upvote 0

PJLPJLPJL

Member
Licensed User
Thank you Erel.
Now this may be a very specific problem relating to something I'm doing or to the particular website I'm loading. But when I do the download request in a resumable sub in a B4XPages page, I still sometimes get the error mentioned. It happens only ever on the first attempt to download (pressing the button again works normally) and it doesn't always happen on the first time!
Here is a sample log where it does happen:

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
sending message to waiting queue of uninitialized activity (submitjob)
*** Receiver (httputils2service) Receive (first time) ***

I've attached a test project which (sometimes) demonstrates this.
Thank you for your help. With best wishes.
 

Attachments

  • Test.zip
    10.3 KB · Views: 143
Upvote 0
Top