I am running a
Service and am wondering in the rare case that my app crashes will it automatically kill my
Service too? I don't want it continuing if this happens.
If not, is there a way to do this such as in the
I've done a bit of research, and I think I have a complete answer to your question.
Service is fine, assuming you're not using a Remote Service (a
Service in a different process.) Assuming your
Service is in the same process as your
Activity, they'll both end together, in the event of a crash. That being the case, my earlier suggestion to use
BoundService wouldn't have actually produced a different result and was based on a flawed understanding of how Application Components work in Android processes.
Service is running in the same process as other components (i.e. activity that bound to it) from the same application, when this single application-scoped process has crashed or been killed, it is very likely that all components in this process (include the activity that bound to this service) are also destroyed.
Also, you can read Remote Service Vs. Local Service.