Help with Service

anaylor01

Well-Known Member
Licensed User
Longtime User
The code below is what I am using. I did get it to work but now I am trying to send a text message from the service. My thought process is basically that I need to copy the already working code in my activity to the service. Is this correct? And if so I am thinking would place that code under Sub Service start. Is that right?
Sub Process_Globals
Dim Timer1 As Timer
Timer1.Initialize("Timer1",1000)
end sub

Sub Button1_Click
Timer1.Enabled=True
StartService(TestService)
End Sub

Sub Timer1_Tick
Label1.Text=TestService.Counter
End Sub
Sub Process_Globals
Dim TimerService As Timer
Dim Counter As Int
Counter=0
End Sub

Sub Service_Create
TimerService.Initialize("TimerService",1000)
TimerService.Enabled=True
End Sub

Sub Service_Start
Counter=Counter+1
End Sub
...
...
Sub TimerService_Tick
StartServiceAt("", DateTime.Now, True)
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I recommend you to use the code tags when posting code. It will make your posts clearer.

Did you post your activity code or your service code? You should only use StartServiceAt if you need to schedule your service to start at a specific time, otherwise just use StartService.

Do you want to show the text of the messages that your application sent?
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
I have a label on the activity layout that I want to show the number that the text was sent too. I have everything working on the activity like I want I just want to be able to have it run in the background.
 
Upvote 0
Top