Hello
I have a Start button and a Stop button, they initiate or stopping a service module each time X has to stop i just send a notice if you want to start the service module, if the timer is in the Main application module when is open but if this works in pause or closed ends when the service module start counting again. If the timer is in the service module does not work.
As I do to stop it when the Activity is paused or closed?
where I put the timer on the Main or the Service Module?
Can a service module stop or destroy the same?
MAIN module
Sub btnStart_Click
timer1.enabled=True
StartService(Temporitzador)
End Sub
Sub btnStop_Click
timer1.Enabled=False
StopService(Temporitzador)
CancelScheduledService(Temporitzador)
End Sub
Service Module Temporizador
Sub Process_Globals
Dim counter As Int
Dim timer As Timer
End Sub
Sub Service_Create
counter = 10
timer.Initialize("timer",1000)
End Sub
Sub Service_Start (StartingIntent As Intent)
timer2.Enabled = True
StartServiceAt("", DateTime.Now + counter * DateTime.TicksPerSecond, True)
End If
End Sub
Sub Service_Destroy
End Sub
Sub timer2_Tick
counter = counter - 1
If counter = 0 Then
StopService("")
CancelScheduledService("")
timer2.Enabled=False
ToastMessageShow("Stop temporitzador" ,True)
End If
End Sub
if I remove the timer2.enabled = false works but I have another problem, if you start the Service Module and turn off the application when the service ends then restarts, how to solve this problem?
Thank you.