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

vecino

Well-Known Member
Licensed User
Longtime User
Hello, I have searched the forums and I have seen several messages with the same error, although in no case I have found what the solution is, or why the error occurs.
The problem is that it occurs on some devices, however on others it works fine.
Any idea what I should change to make it work on all devices?
Thanks.

B4X:
Wait For(WSCallSoapURL(WSLinkSoap, cParams.ToString)) Complete (Result As String)


Public Sub WSCallSoapURL(URL As String, Parameters As String) As ResumableSub
    Dim Result As String
    Dim j As HttpJob
    Try
        j.Initialize("", Me)
        j.PostString (URL, Parameters)
        j.GetRequest.SetHeader("Content-Type","text/xml")
        j.GetRequest.SetHeader("Content-length", Parameters.Length)              
        Wait For (j) JobDone(j As HttpJob)      ' <-- Here is the error.
        If j.Success Then
            Result = j.GetString
        Else
            ToastMessageShow("¡Hummm...!",False)
        End If
    Catch
        Log(LastException)
    End Try
    j.Release
    Return Result
End Sub
 

vecino

Well-Known Member
Licensed User
Longtime User
Hello, thanks for your help.
That message of yours I have read it in another thread, but in this case the call is made from a button pressed by the user.

And also it works on some devices and on others it doesn't work.
And to top it off, on some it works sometimes, and sometimes it doesn't work either.

I'm going crazy.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
call is made from a button pressed by the user.
That is odd, because the button must be visible on an instantiated activity for the user to press it. I wonder if Erel could comment on this.

And to top it off, on some it works sometimes, and sometimes it doesn't work either.
That's usually indicative of a timing/synchronization problem of some sort, but in this case I have no idea.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Where I am having the most problems is with some barcode scanning devices, which are very slow.

https://www.newland-id.com/en/products/micro-kiosks/nquire-750-stingray
nquire_750_stingray_1.png
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hello, I have understood that I should replace this:
B4X:
j.GetRequest.SetHeader("Content-Type","text/xml")
j.GetRequest.SetHeader("Content-length", Parameters.Length)
For this other:
B4X:
j.GetRequest.SetContentType("text/xml")
Is that it?
I have tried it and the result is the same :/

What information can I provide that will help in this case?
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hello, it is really a very small project.
It only has the main activity and another one to configure some parameters.

So far it has worked fine on all the devices where I have tested it. However, it fails on the device it should work on, that barcode reader I posted above.
Even, on that device it has worked sometime when it was in debug mode. But then running normally the program always shows that error message right on the line:
B4X:
Wait For (j) JobDone(j As HttpJob)

I can attach the complete project, it's not a big deal, in theory it's something very simple for those devices, it reads a barcode and queries a database on a server.
Thanks.
 

Attachments

  • damepvp.zip
    19.6 KB · Views: 64
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
What a strange thing to do!
Let's see if this helps to find the solution to the problem:
In debug mode it works if I pause the line a little:
B4X:
Wait For (j) JobDone(j As HttpJob)
Let me explain, I put a breakpoint in the first line:
B4X:
Dim Result As String
I run the program and when it stops on that line I press F9, F9, F9... line by line (or also F8) and when the line arrives:
B4X:
Wait For (j) JobDone(j As HttpJob)
I stop for a second or two and then continue with F9 (F8 or F5) and... It works fine!!!!

I tried in release mode to put a sleep(2000) before but it didn't work.

B4X:
Public Sub WSCallSoapURL(URL As String, Parameters As String) As ResumableSub
    Dim Result As String
    Dim j As HttpJob
    Try
        j.Initialize("", Me)
        j.GetRequest.Timeout = 5000
        j.PostString (URL, Parameters)
        '
        j.GetRequest.SetContentType("text/xml")
        '
'        j.GetRequest.SetHeader("Content-Type","text/xml")
'        j.GetRequest.SetHeader("Content-length", Parameters.Length)       
        '
        Wait For (j) JobDone(j As HttpJob)
        If j.Success Then
            Result = j.GetString
        Else
            Result = "Sin conexión"
        End If
    Catch
        Log(LastException)
        Result = "Sin conexión"
    End Try
    j.Release
    Return Result
End Sub
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I'm probably missing something but I can only get your app to sit and blink a label at me, I can't see how to move on from there.

However there is one obvious mistake, though it may not matter in practice

Subs LoadConfiguracion and SetEstetica are not ResumableSub and should not be declared as such and should be called directly.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
OK. Got it going. Your layout doesn't adapt and the EditText was off screen.

It may be on your slow devices your edrroneous WaitFors are exiting Activity_Create and Activity_Resume and firing the focus changed event before the Activity is fully built.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thanks for the corrections and comments.
The program is really very simple, it displays a text on screen, and when reading a barcode it queries an external database that returns the name of the item and the selling price.
The flashing text just says to pass the barcode.
That's it, no more. There is always that screen with the company name and when the customer swipes a barcode its name and price is queried and displayed to the customer on the screen.
The query to the database is done through a "webservice soap", and that is where the problem with this device is. Because testing with any smartphone or tablet, it works perfectly.
I don't know what else to do :(
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Attached is a video of how the program works.

In order to test it on tablets and smartphones I have added a "barcode reader simulator". By clicking on the bottom right corner you choose a random item code (shown in the EditText on the left side of the screen). And to perform the query of that article code I click on the EditText below it (it is processed when the focus is lost).
That's just an "invention" to test that everything works.
In the device that is going to be used (the one that I put in some message before) this "invention" is not necessary, obviously, because it has a barcode reader.

That's all, it couldn't be simpler.

 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thanks, your program looks very good, I want to do something like that, at the moment I'm just trying to make it work and then I will do the aesthetic part of presentation to the user.

I don't know what to think, maybe this device has some defect.

What I don't understand is that it works fine when I run the program step by step in debug mode.
However, in release mode nothing at all.
 
Upvote 0

Xfood

Expert
Licensed User
at the moment there are none in the laboratory of these devices, I should get about twenty of them, as soon as they arrive I try your program on the device so I can try to verify the problem better

Have you tried doing a factory reset of the device?
 
Upvote 0
Top