Android Question Update B4A app label text from service

sweddle

Member
Licensed User
Longtime User
Hello,

I have B4A app that has a button that when clicked starts a service and in the same app I have a label named lblSTAT.

I would like for the service I made in B4A and started via the app to be able to update the text of the app.

But I'm not sure how to do that or make the call from the service to update the label.. I tried

lblSTAT.Text = "Hello world"

but no luck

Thanks for any help!
Shane
 

Troberg

Well-Known Member
Licensed User
Longtime User
It's always a good practice to not set internal stuff in one component from another component directly.

Instead, add a sub to the activity, such as:

B4X:
Sub SetStat(text as string)
  lblSTAT.Text = "Hello world"
End Sub

Then, use CallSubDelayed as Erel suggested to call that sub. That way, you'll get all the external connections properly documented, which is a godsend when you start changing stuff a month later...
 
Upvote 0
Top