Android Question Service - What happens if started again?

FrankBerra

Active Member
Licensed User
Longtime User
Hi

I developed an app that has a service running aturomatically (StarServiceAt) in background at specified intervals. The service can also be started manually (by pressing a button) and it takes about 15 seconds to complete the whole computation.
Everything is going fine but i must foresee all possible scenarios.

My question is:
If the service is already started and it is in the middle of its computations, what happens if i start again manually the service?
In this case the routines in the previous service-runtime are interrupted or service continue to run until the end?
If in the service i write files with discrete amount of data, starting manually the service in the middle of this operations can break up the saved data?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Remember that the service code is executed on the main thread.
2. Service_Start will be raised whenever the service is started. Service_Create will be raised once (unless you destroy the service).

n this case the routines in the previous service-runtime are interrupted or service continue to run until the end?
As the code is executed on the main thread, it will not be interrupted. The same is true about the file writing.
 
Upvote 0
Top