Android Question wait for Error

hello
i use wait for in other module

B4X:
public Sub sendToUrl(   url As String ) As ResumableSub
    'Log(Sender.As(B4XPagesManager.GetPageInfoFromRoot.B4XPage.))'
    LogColor(DateTime.Now,Colors.Magenta)
   
    Dim j1 As HttpJob
    j1.Initialize("", Sender)
    j1.Download(url)'"https://www.google.com")
    Wait For (j1)     JobDone(j  As HttpJob)
    If j .Success Then
        Dim str1 As String =j.GetString
        LogColor(str1,Colors.RGB(45,45,45))
 
    Else
        LogColor("Error..",Colors.Red)
    End If
    j.Release
   
    LogColor(DateTime.Now,Colors.Blue)
    Return False'
End Sub


if i use this code in root of each page, it work true


but if i copy this code in "Code Module" class it told cannot use wait in static function

"Error description: Static code modules cannot handle events."

plz help

thanks
 


hello

inside class have this error and cannot use this module.

i use this code in main

Dim ClassObject As httpclass2
ClassObject.Initialize




this is in main
 
Last edited:
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Not properly awake yet, but shouldnt it be Class_Globals and not Process_Globals in a class?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
inside class have this error and cannot use this module
It is NOT A CLASS. See Line 1 of httpclass2. It is a codemodule.
Static modules can not handle events.

The solution ist to switch to a Class, a Service or an Activity.
Best is to use B4XPages.
Remember that B4XPage pages are classes.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
inside class have this error
What we are trying to say is that you're not using a class, but a code module.

Add a "Standar class" and copy the code from your "Code Module" called http2class to the new created (and real) class

 
Upvote 0
What is the error?

What we are trying to say is that you're not using a class, but a code module.

Add a "Standar class" and copy the code from your "Code Module" called http2class to the new created (and real) class

View attachment 162279
ok
it have not Error.
but on run project wait on this line
"Wait For (j1) JobDone(j1 As HttpJob)"
in mainpage this line work true but it this class only wait


in main i use this:


Dim ClassObject As httpclass3
ClassObject.Initialize
ClassObject.sendToUrl( "http://1xxxx3:8891/token?User=1&Pass=1")

 
Upvote 0
It is NOT A CLASS. See Line 1 of httpclass2. It is a codemodule.
Static modules can not handle events.

The solution ist to switch to a Class, a Service or an Activity.
Best is to use B4XPages.
Remember that B4XPage pages are classes.
when we can use "code module" and when we can use "standard class"? i need more info. have you manual or datasheet in this way?
thanks
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

josejad

Expert
Licensed User
Longtime User
read docs

but cannot see any about different between code module and standard module.


 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…