Android Question Update B4A app label text from service

Discussion in 'Android Questions' started by sweddle, Mar 18, 2015.

  1. sweddle

    sweddle Member Licensed User


    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!
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Troberg

    Troberg Well-Known Member Licensed 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:

    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...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice