Android Question 4 instances of startserviceat

jimseng

Active Member
Licensed User
Longtime User
Hello
I have an application with 4 buttons to control a bluetooth relay board. If I turn a relay on and want to automatically turn it off after say 30 minutes I imagine I should use StartServiceAt. My question is would I need a service module for each button? For example, I might switch a couple of buttons several minutes apart so I wonder if I would have a service module assigned to each button.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use a single service. However it will be (a bit) more complicated as each call to StartServiceAt will replace the previous scheduled task. So you will need to maintain a sorted list of tasks and schedule the next one.

With 4 services you will not have this problem. You can implement the code in a class and then use the class from the 4 services.
 
Upvote 0
Top