Mark M. |
has entered the room |
Mark M. |
turned on guest access |
Steve S. |
has entered the room |
Mark M. |
hello, Steve!
|
Mark M. |
how can I help you today?
|
Steve S. |
Hi, Mark!
|
Steve S. |
I wanted to follow up with you regarding the Bluetooth service I'm working on
|
Steve S. |
Based on discussions we've had in the past, I know I need to allow for the possibility that the service will be (temporarily) shut down by the system from time to time.
|
Steve S. |
One question is:
|
Steve S. |
What is the best way to tell whether the service is running so I can check that before trying to send a message via Bluetooth?
|
Mark M. |
why do you need to know if the service is running before trying to send a message via Bluetooth
|
Mark M. |
?
|
Mark M. |
I don't remember the details of your service, but, in general, if you want to ensure that the service is running, call startService()
|
Jun 27 |
7:30 PM |
Steve S. |
Messages are used to start a brew operation (this is for a coffee brewer). There shouldn't be a delay between pressing the button and sending the message from the app to the microcontroller.
|
Mark M. |
so, don't enable the button until you have established whatever sort of communications you are doing with the service
|
Steve S. |
Sure
|
Steve S. |
What I'm referring to are cases where the system brings down the service e.g. for garbage collection
|
Mark M. |
is the service in a separate process from the UI?
|
Steve S. |
No
|
Mark M. |
then *everything* is gone
|
Mark M. |
there is no "brings down the service"
|
Mark M. |
unless you stop the service yourself, of course
|
Steve S. |
ok
|
Mark M. |
Android won't do that individually automatically -- it terminates the whole process
|
Mark M. |
and so long as your UI is in the foreground, Android should not do that, outside of a very sick environment
|
Mark M. |
so, if the UI and the service are in the same process, they represent an atomic unit of stuff
|
Steve S. |
Ok. So as long as the activity is running, the service will run as well
|
Mark M. |
if the activity is doing something to start or bind to the service, yes
|
Steve S. |
Yes, this is a started service
|
Jun 27 |
7:35 PM |
Steve S. |
Then that makes things much easier
|
Steve S. |
No more questions today - I had some more based on an incorrect assumption about the service lifetime
|
Mark M. |
OK
|
Steve S. |
Thank you so much, Mark!
|
Mark M. |
you're welcome!
|
Steve S. |
Have a good rest of the day!
|
Mark M. |
you too!
|
Steve S. |
has left the room |
Jun 27 |
8:30 PM |
Mark M. |
turned off guest access |