Android Question ByRef

Clayton

Member
Licensed User
Longtime User
Hello, I have the following situation ...

I have a Sub in a module. that checks if the connection to the internet ..

B4X:
If T.DataConnection = False Then
T.TurnDataConnectionOn 'Enables Conexao Data GPRS / EDGE / HSPA
Error = False
While the T.DataConnection = False
A = (DateTime.Now - HoraIncio) / (DateTime.TicksPerSecond)
Status_Conexao = "Enabling Connection Provider (" & Num & ")"
If Num> = TimeOut Then
Error = True
Exit
end If
DoEvents
Loop

I call this a sub ACTIVY .. I need to capture the value of the variable Status_Conexao and play within a label such as ACTIVY do it?



sorry my english
 

wl

Well-Known Member
Licensed User
Longtime User
It seems you'd better execute this code in a service (background task). Within the service (within your loop) you can call a method in your activity that updates the label by using CallsubDelayed2.

Wim
 
Upvote 0

Clayton

Member
Licensed User
Longtime User
Ok thank you , but I decided to create a class and inside the loop it calls a sub activy of this sub updates the label , it was cool
 
Upvote 0

wl

Well-Known Member
Licensed User
Longtime User
Be careful: code executed in a class is part of the thread in which the class is being used, just as all other code.
So: if you create a class in the activity code, all methods of the class executed are running in the thread of the activity. And as was confirmed by Erel: you should not execute long running code in an activity.
 
Upvote 0
Top