Android Question StartServiceAt and how to kill previous services

Daniel-White

Active Member
Licensed User
Longtime User
Hi folks.

One simple question. I have an APP which service is running each 2 minutes with
StartServiceAt("", DateTime.Now + 120 * 1000, False) and show a toastmessage("service running")

works great, each 2 minutes show "service running" in screen. ok

I put a button to stop the service with CancelScheduledService(Test) and stop the service and later , ExitApplication. ok
that is working. kill everything.

Why if I go to desktop and select the icon of my APP, and run it again, over and over, I have a lot of services running, and of course, I will see a lot of toast with " service running"

I put the CancelScheduledService(Test) in Sub Activity_Create(FirstTime As Boolean) with the idea to kill previous services from old running APP in RAM.


I am looking to do this, perhaps the approach is not good, if the user call again from desktop, the APP , stop the previous service "Test" with the idea leave only one running.
Thanks you
 

Daniel-White

Active Member
Licensed User
Longtime User
Erel, I did exactly what you told me.
I used StopService later CancelScheduleService, and in the end , Activity.finish instead ExitApplication. and now work fine :)
Thanks you Indeed.
Daniel White
 
Upvote 0
Top