Android Question Refresh Label.Text from Service [SOLVED]

AHilberink

Active Member
Licensed User
Longtime User
Hi,

I have a Panel.Text containing the miles driven. I want to update this on the fly with information from my GPS service. A panel cannot be defined within Global, so I don't know how to this.

Will this be possible?

Kind regards,
André
 

DonManfred

Expert
Licensed User
Longtime User
Look how it is done here:
 
Upvote 1

AHilberink

Active Member
Licensed User
Longtime User
Look how it is done here:

Thank you DonManfred,

Sorry for my unclear question. I already have GPS working, based on this example. This example sends notifications.

I only need to refresh a panel.text within my main activity form with the new gps information from the service.

Kind regards,
André
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
What exactly do you want to update.
Where does the data come from and at what frequency ?
What amount of data do you want to display ?
Without knowing more in detail what you want to do it difficult to give a concrete advice.
You can have a variable containing the text and reset the Label.Text property.
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
What exactly do you want to update.
Where does the data come from and at what frequency ?
What amount of data do you want to display ?
Without knowing more in detail what you want to do it difficult to give a concrete advice.
You can have a variable containing the text and reset the Label.Text property.

Hi Klaus,

I hope this will help:
B4X:
Sub Process_Globals
    Dim KM as String
End Sub

Sub Globals
    Dim lblKM as Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
.......

    lblKM.Text="Miles driven: "&KM
End Sub

From my GPS Service I want to update KM in the background and need to refresh the lblKM.Text every time.

Kind regards,
André
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
And what is KM ?
And all this in the background !
You need to search in the forum on how to manage GPS in the background, i have never used it.
With what frequency do you want to update the driven distance.
Do you actually already read the data given in the GPS.LocationChanged event ?
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
And what is KM ?
And all this in the background !
You need to search in the forum on how to manage GPS in the background, i have never used it.
With what frequency do you want to update the driven distance.
Do you actually already read the data given in the GPS.LocationChanged event ?

Hi Klaus,

Thank you for your reply.

I just found a solution.
Made this Sub:
B4X:
Sub Update_KM
    lblKM.Text="Miles driven: "&KM
End Sub

and called it from the Service module after every update of the KM string.

Kind regards,
André
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Yiou need to also correct the title of your thread: Panel.Text should be Label.Text. You were so excited to mark your thread as 'Solved' that you forgot to make the title correction. Leaving it the way it is can really confuse many members, particularly noobies.

 
Last edited:
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
Yiou need to also correct the title of your thread: Panel.Text should be Label.Text. You were so excited to mark your thread as 'Solved' that you forgot to make the title correction. Leaving it the way it is can really confuse many members, particularly noobies.


You are right. Just changed it :)
 
Upvote 0
Top