Can you have two background services in your Android app running at the same time?

1.6k views Asked by At

I have two services in my App that do different things on the device. I might need to run the second one while the first one is running in the background. I am just wondering if that might create an issue on some Android versions?

1

There are 1 answers

0
Larry Schiefer On

This is a perfectly acceptable use case. Each instance of a Service is a separate object, running within your app's process. Do note, however, that a Service's callbacks (onStartCommand(), onBind(), etc.) are all run in the context of the main thread of your application. You'll need to follow the best practices and guidelines for using background threads to do work in order to not starve off the other Service or any Activity which is active.