I have implemented a simple Android Service
that, by default, is deployed within the same process as my app / apk. I want the Service running concurrently with each Activity
. To make that happen, in each Activity.onStart()
and Activity.onStop()
implementation, I have logic that invokes Activity.bindService()
and Activity.unbindService()
, respectively.
Well, all of this works fine, but it feels awkward. Is there any other way to make sure the Service
is continuously running and bound to all Activities without having to re-invoke Activity.bindService()
and Activity.unbindService()
for each Activity? Should the Service
in this case be declared as a stand-alone process?
Also, my Service starts a separate thread, but never stops it. Should my code stop the thread? Is there a chance the thread could be orphaned? Starting / stopping the thread with OnUnbind
/ OnRebind
seems like overkill.